Diff for "AutomaticAnalysisManual" - MRC CBU Imaging Wiki
location: Diff for "AutomaticAnalysisManual"
Differences between revisions 10 and 56 (spanning 46 versions)
Revision 10 as of 2006-06-02 00:37:31
Size: 17969
Editor: RhodriCusack
Comment:
Revision 56 as of 2013-03-07 21:24:14
Size: 17280
Editor: localhost
Comment: converted to 1.6 markup
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
http://www.mrc-cbu.cam.ac.uk/~rhodri/aa/aa_topbar.gif

'''aa release 1.1''' Rhodri Cusack, MRC CBU, Cambridge __rhodri.cusack [at] mrc-cbu.cam.ac.uk__

Acknowledgements: Thank you to Matthew Brett, Jessica Grahn, Daniel Mitchell, Rik Henson & Matt Davis, who have contributed to the code and this manual.

See also AutomaticAnalysis, AutomaticAnalysisManualReference

= CONTENTS =
'''Table Of Contents'''

|| ||[#s Summary] ||
|| ||[#s Main Features] ||
|| ||[#s System overview] ||
|| ||[#s User script] ||
|| ||[#s4. Overview] ||
|| ||[#s4. Choosing the recipe] ||
|| ||[#s4. Modify parameter set selection] ||
|| ||[#s4. Setting your acquisition parameters] ||
|| ||[#s4. Set specific parameters that you wish to differ from the defaults] ||
|| ||[#s Everyday tasks] ||
|| ||[#s5. Getting ready to use AA] ||
|| ||[#s5. Running an analysis] ||
|| ||[#s5. Restarting an analysis] ||
|| ||[#s5. How do I force an analysis to start all over again?] ||
|| ||[#s5. How do I force an analysis to start from a particular stage?] ||
|| ||[#s Pitfalls - beware!] ||
|| ||[#s6. Check your data] ||
|| ||[#s6. Changing the aa_user script] ||


[Anchor(s)]]

= Summary =
The system automates the analysis of neuroimaging data. This version has been configured to work on data from the Wolfson Brain Imaging Centre, reading Bruker data and analysing it with SPM. It is written in Matlab.

[[Anchor(s)]]
= Main Features =
 * '''''Automatic. '''''Almost completely automatic analysis, currently up to the end of normalisation.

 * '''''Flexible control. '''''Users that are new to neuroimaging don’t get bombarded with options, but are directed to what is essential, while all other settings take sensible defaults. More experienced users can easily change a range of settings, and advanced users can add or replace modules to the system to change any behaviour

 * '''''Restartable.''''' If the users stops the script, or if it crashes (e.g., because of a machine fault, or because the right data aren’t there) then when restarted it will begin at the stage where it left off.

 * '''''Modular. '''''The system is modular at two levels, to make it easy to switch in or out relevant parts.

 * '''''Automatic good citizen behaviour.''''' Field maps and structurals are automatically detected. Structurals are copied to /imaging/local/structurals/cbu automatically by default.

 * '''''Easy to maintain. '''''The code components are stored in a central repository (/cbu/imagers/spm/aa ?) which means that new components can be made available, or existing ones changed in new releases

 * '''''Record keeping. '''''Unlike SPM used from the GUI, the system records exactly which parameters were used, and allows easy recreation of a dataset from the raw data at a later date.

 * '''''Simple interface for new modules. '''''It is easy for Matlab programmers to write new modules and incorporate them into the processing stream.

[[Anchor(s)]]
= System overview =
<<Include(AutomaticAnalysisTopbar)>>
----
 . '''Contents '''<<TableOfContents>>

----
 . For an overview of the benefits of using aa see AutomaticAnalysisIntroduction

<<Anchor(s)>>
= Overview =
== The components ==
=== The modules ===
aa has a modular design. Each module handles a single task, which may be peformed once per study, per subject or per session. All modules have a name that begins "aamod_" (e.g., aamod_realign). There are a few modules that process your input parameters or perform other setup tasks, which are run every time you launch an aa analysis. These are called "initialisation modules".

=== The engine ===
The engine (usually via the aa_doprocessing command) takes a description of the tasks you wish to perform, and then runs the appropriate modules. It also provides a number of helper subroutines to support the modules (beginning aas_), and also some useful utilities such as the aa_benchmark command to measure analysis times, and the aa_report tool to generate an HTML summary.

=== Specifying an analysis ===
The components of the aa system are arranged in a hierarchy. At the top ''recipes'' describe whole processing pipelines. They are made up of a selection of ''parameter sets, ''each of which defines a group related parameters. Finally, the individual ''parameters'' actually specify what happens. aa recipes begin with 'aarecipe_' and parameter sets 'aap_'

In your user script you must choose a recipe. If you wish, you may then override single parameters. Occasionally, you may also wish to override whole parameter sets from a recipe chosen.

The entire specification is contained in a single Matlab structure, usually called 'aap'. This has many elements, to store each of the paramter sets, and one that specifies the SPM default settings.
Line 59: Line 26:
||<style="vertical-align: top;">''Component'' ||<style="vertical-align: top;">''Description'' ||<style="vertical-align: top;">''Location of file'' ||<style="vertical-align: top;">''Expertise needed to write new ones'' ||
||<style="vertical-align: top;">User script ||<style="vertical-align: top;">In overall control. Selects a recipe, adds study specific information, and changes any defaults ||<style="vertical-align: top;">User's directory ||<style="vertical-align: top;">Beginner ||
||<style="vertical-align: top;">Recipes ||<style="vertical-align: top;">Specifies which parameter sets to use ||<style="vertical-align: top;">Centrally ||<style="vertical-align: top;">Beginner/ Intermediate ||
||<style="vertical-align: top;">Parameter sets ||<style="vertical-align: top;">Set default parameters. There are five different basic types of parameter set ||<style="vertical-align: top;">Centrally ||<style="vertical-align: top;">Intermediate ||
||<style="vertical-align: top;">Modules ||<style="vertical-align: top;">Run individual stages of processing ||<style="vertical-align: top;">Centrally ||<style="vertical-align: top;">Advanced ||
||<style="vertical-align: top;">Engine ||<style="vertical-align: top;">Main automatic analysis engine, which contols module execution ||<style="vertical-align: top;">Centrally ||<style="vertical-align: top;">Advanced ||


= =The most important of these by far from the user’s point of view is the “User script”. The next section describes this. [[Anchor(s)]]
||<style="VERTICAL-ALIGN: top">''Component'' ||<style="VERTICAL-ALIGN: top">''Description'' ||<style="VERTICAL-ALIGN: top">''Location of file'' ||<style="VERTICAL-ALIGN: top">''Expertise needed to write new ones'' ||
||<style="VERTICAL-ALIGN: top">User script ||<style="VERTICAL-ALIGN: top">Sets up a description of the analysis to be performed. Selects a recipe, adds study specific information, and changes any defaults ||<style="VERTICAL-ALIGN: top">User's directory ||<style="VERTICAL-ALIGN: top">Beginner ||
||<style="VERTICAL-ALIGN: top">Recipes ||<style="VERTICAL-ALIGN: top">A full description of the processing pipeline. This is implemented by choosing a group of parameter sets. ||<style="VERTICAL-ALIGN: top">Centrally ||<style="VERTICAL-ALIGN: top">Beginner/ Intermediate ||
||<style="VERTICAL-ALIGN: top">Parameter sets ||<style="VERTICAL-ALIGN: top">Groups of related parameters. There are five different basic types of parameter set ||<style="VERTICAL-ALIGN: top">Centrally ||<style="VERTICAL-ALIGN: top">Intermediate ||
||<style="VERTICAL-ALIGN: top">Modules ||<style="VERTICAL-ALIGN: top">Run individual stages of processing ||<style="VERTICAL-ALIGN: top">Centrally ||<style="VERTICAL-ALIGN: top">Some Matlab experience ||
||<style="VERTICAL-ALIGN: top">Engine ||<style="VERTICAL-ALIGN: top">Main automatic analysis engine, which contols module execution ||<style="VERTICAL-ALIGN: top">Centrally ||<style="VERTICAL-ALIGN: top">Advanced ||


The most important of these by far from the user’s point of view is the “User script”. The next section describes this. <<Anchor(s)>>
Line 70: Line 37:
[[Anchor(s4.)]]
== 4.
Overview ==
This is the master script, which controls the analysis. Most studies can be analysed with this alone.

There are 6 sections to the user script:

 .
''Section'' ||<style="vertical-align: top;">''Probability  you need to change it and when'' ||

||<style="vertical-align: top;
">1 ||<style="vertical-align: top;">Choosing a recipe ||<style="vertical-align: top;">(0.2) If you use a non-standard acquisition sequence or wish to do a quite different type of analysis ||
||<style="vertical-align: top;">2 ||<style="vertical-align: top;">Changing any of the parameter sets in the recipe ||<style="vertical-align: top;">(0.1) If you wish to change a single parameter set controlling part of the automatic processing from what is specified in a recipe ||
||<style="vertical-align: top;">3 ||<style="vertical-align: top;">Initialising using the parameter sets ||<style="vertical-align: top;">(0.01) Usually never ||
||<style="vertical-align: top;">4 ||<style="vertical-align: top;">Setting study specific details ||<style="vertical-align: top;">(1.0) Always ||
||<style="vertical-align: top;">5 ||<style="vertical-align: top;">Set any other parameters that need to differ from the defaults ||<style="vertical-align: top;">(0.6) If you wish to change single parameters ||
||<style="vertical-align: top;">6 ||<style="vertical-align: top;">Calling aa_doprocessing to do the processing[[BR]] ||<style="vertical-align: top;">(0.01) Usually never||


An example, which will process 3 subjects each with 4 sessions up to and including normalisation is below:

An example, which will process 3 subjects each with 4 sessions up to and including normalisation is below:

% Automatic analysis
== Overview ==
This specifies an analysis. Many studies can be analysed up to and including the stage of normalisation with changes to this alone. With some changes to the specificaiton of the experimental design in aamod_model_firstlevel, you may run all the way up to and including second level statistics.

There are sections to the user script:

||<style="VERTICAL-ALIGN: top"> ||<style="VERTICAL-ALIGN: top">
''Section'' ||<style="VERTICAL-ALIGN: top">''Probability you need to change it and when'' ||
||<style="VERTICAL-ALIGN: top">1 ||<style="VERTICAL-ALIGN: top">Choosing a recipe ||<style="VERTICAL-ALIGN: top">(0.2) If you use a non-standard acquisition sequence or wish to do a quite different type of analysis ||
||<style="VERTICAL-ALIGN: top">2 ||<style="VERTICAL-ALIGN: top">Changing any of the parameter sets in the recipe ||<style="VERTICAL-ALIGN: top">(0.1) If you wish to change a single parameter set controlling part of the automatic processing from what is specified in a recipe ||
||<style="VERTICAL-ALIGN: top">3 ||<style="VERTICAL-ALIGN: top">Initialising using the parameter sets ||<style="VERTICAL-ALIGN: top">(0.01) Usually never ||
||<style="VERTICAL-ALIGN: top"> ||<style="VERTICAL-ALIGN: top">Setting study specific details ||<style="VERTICAL-ALIGN: top">(1.0) Always ||
||<style="VERTICAL-ALIGN: top"> ||<style="VERTICAL-ALIGN: top">Set any other parameters that need to differ from the defaults ||<style="VERTICAL-ALIGN: top">(0. If you wish to change single parameters ||


||<style="vertical-align: top;">

||<style="VERTICAL-ALIGN: top
">Calling aa_doprocessing to do the processing<<BR>> ||<style="VERTICAL-ALIGN: top">(0.01) Usually never||


An example, which will process 3 subjects each with sessions up to and including normalisation is below:

----
''% Auto
matic analysis ''
Line 94: Line 62:
% Rhodri Cusack MRC CBU Cambridge 2005 % Rhodri Cusack MRC CBU Cambridge 200
Line 102: Line 70:
%  General auto TR recipe; slice order Siemens product sequence default

aap=aarecipe_general(aap);
% General auto TR recipe; slice order Siemens product sequence default

aap=aarecipe_general_ver01(aap);
Line 110: Line 78:
% (4) GET ALL THE PARAMETERS FOR THIS RECIPE % ( GET ALL THE PARAMETERS FOR THIS RECIPE
Line 114: Line 82:
% (5) DEFINE STUDY SPECIFIC PARAMETERS % ( DEFINE STUDY SPECIFIC PARAMETERS
Line 124: Line 92:
aap=aas_addsubject(aap,'*CBU050011/*',[5 11]);

aap=aas_addsubject(aap,'*CBU050012/*',[4 10]);
aap=aas_addsubject(aap,'*CBU0011/*',[11 12]);

aap=aas_addsubject(aap,'*CBU0012/*',[12 10]);
Line 136: Line 104:
% (6) SET ANY OTHER PARAMETERS YOU WOULD LIKE TO BE DIFFERENT FROM THE DEFAULTS

'''% '''(7) SET ANY SPM DEFAULTS IF NEEDED

'''aap.spm.defaults.normalise.write.vox=[3 3 3];'''
% ( SET ANY OTHER PARAMETERS YOU WOULD LIKE TO BE DIFFERENT FROM THE DEFAULTS

% (7) SET ANY SPM DEFAULTS IF NEEDED

aap.spm.defaults.normalise.write.vox=[3 3 3];
Line 146: Line 114:
The four sections you are mostly likely to need to change (1, 2, 4 and 5) are now discussed in turn.

[[Anchor(s4.)]]
== 4. Choosing the recipe ==
----
The four sections you are mostly likely to need to change (1, 2, and are now discussed in turn.

NB: Be careful about changing the aa_user script after you’ve run part of an analysis. The problem with doing this is that if the changes you make would have affected the parts that have already been completed, you won’t be able to use the script to exactly recreate your data in future.

<<Anchor(s)>>
== Choosing the recipe ==
Line 157: Line 128:
An example recipe is shown below. Descriptions of the parameter sets are in the next section. A full list of recipes is in the “Reference” section.

||''Name:  '' || ||aarecipe_general ||
An example recipe is shown below. Descriptions of the parameter sets are in the next section. A full list of recipes is on the AutomaticAnalysisManualReference page.

||''Name: '' || ||aarecipe_general ||
Line 162: Line 133:
||<style="vertical-align: top;">''Type'' ||<style="vertical-align: top;">''Parameter set'' ||
||<style="vertical-align: top;">directory_conventions ||<style="vertical-align: top;">aap_directory_conventions_ver00 ||
||<style="vertical-align: top;">options ||<style="vertical-align: top;">aap_options_ver00 ||
||<style="vertical-align: top;">tasklist ||<style="vertical-align: top;">aap_tasklist_cbudefault_ver00 ||
||<style="vertical-align: top;">spmanalysis ||<style="vertical-align: top;">aap_spmanalysis_tr1p1_ver00 ||
||<style="vertical-align: top;">acq_details ||<style="vertical-align: top;">aap_acq_details_ver00 ||


[[Anchor(s4.)]]
== 4.
Modify parameter set selection ==
A recipe comprises a description of the parameter sets that should be included. Once you’ve chosen a recipe you may override some of the different parameter sets.  You would do this in stage 2 of the user script (see Error! Reference source not found.) with a line like

|| ||aap.recipe.directory_conventions=
aap_directory_conventions_mynewstyle’ ||
||<style="VERTICAL-ALIGN: top">''Type'' ||<style="VERTICAL-ALIGN: top">''Parameter set'' ||
||<style="VERTICAL-ALIGN: top">directory_conventions ||<style="VERTICAL-ALIGN: top">aap_directory_conventions_ver00 ||
||<style="VERTICAL-ALIGN: top">options ||<style="VERTICAL-ALIGN: top">aap_options_ver00 ||
||<style="VERTICAL-ALIGN: top">tasklist ||<style="VERTICAL-ALIGN: top">aap_tasklist_cbudefault_ver00 ||
||<style="VERTICAL-ALIGN: top">spmanalysis ||<style="VERTICAL-ALIGN: top">aap_spmanalysis_tr1p1_ver00 ||
||<style="VERTICAL-ALIGN: top">acq_details ||<style="VERTICAL-ALIGN: top">aap_acq_details_ver00 ||


<<Anchor(s)>>
==
Modify parameter set selection ==
A recipe comprises a description of the parameter sets that should be included. Once you’ve chosen a recipe you may override some of the different parameter sets. You would do this in stage 2 of the user script (see above) with a line like

||aap
.recipe.directory_conventions=’aap_directory_conventions_mynewstyle ||
Line 179: Line 150:
There are 5 different types of parameter sets. A full list of the available parameter sets is given in the “Reference” section.

||<style="vertical-align: top;">''Type'' ||<style="vertical-align: top;">''Description'' ||
||<style="vertical-align: top;">directory_conventions ||<style="vertical-align: top;">Specifies directory and file conventions, for example:[[BR]]- directory names for each subject (4d_files, proc_fieldmaps etc.)[[BR]]- raw data directory (by default /cbu/wbic_data)[[BR]] ||
||<style="vertical-align: top;">options ||<style="vertical-align: top;">General aa program options, for example:[[BR]]- whether to automatically identify the field maps and SPGR in the incoming dataset[[BR]]- whether to copy structurals to the central store ||
||<style="vertical-align: top;">tasklist ||<style="vertical-align: top;">The list of tasks to be performed (e.g., modules to be executed) for each study ||
||<style="vertical-align: top;">spmanalysis ||<style="vertical-align: top;">SPM & imaging analysis parameters, for example:[[BR]]- TR & slice acquisition time[[BR]]- smoothing FWHM[[BR]]- evolution time of fieldmaps ||
||<style="vertical-align: top;">acq_details ||<style="vertical-align: top;">Acquisition details. Several of the defaults are overridden in the user script, for example:[[BR]]- study directory[[BR]]- subject list ||


[[Anchor(s4.)]]
== 4. Setting your acquisition parameters ==
There are different types of parameter sets. A full list of the available parameter sets is given in the AutomaticAnalysisManualReference section.

||<style="VERTICAL-ALIGN: top">''Type'' ||<style="VERTICAL-ALIGN: top">''Description'' ||
||<style="VERTICAL-ALIGN: top">directory_conventions ||<style="VERTICAL-ALIGN: top">Specifies directory and file conventions, for example: raw data directory (by default /mridata/cbu) ||
||<style="VERTICAL-ALIGN: top">options ||<style="VERTICAL-ALIGN: top">General aa program options, for example: whether to automatically identify the field maps and structurals in the incoming dataset; whether to copy structurals to the central store ||
||<style="VERTICAL-ALIGN: top">tasklist ||<style="VERTICAL-ALIGN: top">The list of tasks to be performed (e.g., modules to be executed) for each study ||
||<style="VERTICAL-ALIGN: top">spmanalysis ||<style="VERTICAL-ALIGN: top">SPM & imaging analysis parameters, for example: TR & slice acquisition tim; smoothing FWHM; evolution time of fieldmaps ||
||<style="VERTICAL-ALIGN: top">acq_details ||<style="VERTICAL-ALIGN: top">Acquisition details. Several of the defaults are overridden in the user script, for example:<<BR>>- study directory<<BR>>- subject list ||


<<Anchor(s)>>
== Setting your acquisition parameters ==
Line 193: Line 164:
||<style="vertical-align: top;">aap.acq_details.root = '/cbu/scratch2/rhodri.cusack/newsimultaneous';[[BR]] ||<style="vertical-align: top;">Specifies the directory where the processed study data are stored. This directory should exist before you run the script.||
||<style="vertical-align: top;">aap.acq_details.sessions={'ns1_block1','ns1_block2','ns2_passive','ns2_active'};[[BR]] ||<style="vertical-align: top;">These are names of the blocks in your experiment. This must be the same for all subjects. Here, there were four blocks. I find it easiest to use intuitive names that describe the behavioural condition.||
||<style="vertical-align: top;
">aap.acq_details.numdummies=18;[[BR]] ||<style="vertical-align: top;">Number of dummy scans at the start of each session that need to be thrown away.||
||<style="VERTICAL-ALIGN: top">aap.acq_details.root = '/cbu/scratch2/rhodri.cusack/newsimultaneous';<<BR>> ||<style="VERTICAL-ALIGN: top">Specifies the directory where the processed study data are stored. This directory should exist before you run the script.||
||<style="VERTICAL-ALIGN: top">aap.acq_details.sessions={'ns1_block1','ns1_block2','ns2_passive','ns2_active'};<<BR>> ||<style="VERTICAL-ALIGN: top">These are names of the blocks in your experiment. This must be the same for all subjects. Here, there were four blocks. I find it easiest to use intuitive names that describe the behavioural condition.||
||<style="VERTICAL
-ALIGN: top">aap.acq_details.numdummies=18;<<BR>> ||<style="VERTICAL-ALIGN: top">Number of dummy scans at the start of each session that need to be thrown away.||
Line 200: Line 171:
aap=aas_addsubject(aap, ‘*CBU050011\*’,[5 11]);

The full syntax of this command is in Error! Reference source not found., but the first string specifies the raw data for this subject (you may use wildcards) and the numbers in square brackets the series numbers for the EPI data. There should be as mank of these are there are blocks, as specified in aap.acq_details.sessions and described above.

By default, MPRAGE structural and GRE_FIELDMAPPING fieldmap scans are automatically detected.

[[Anchor(s4.)]]
== 4. Set specific parameters that you wish to differ from the defaults ==
aap=aas_addsubject(aap, ‘*CBU0011\*’,[11]);

The full syntax of this command is in Error! Reference source not found., but the first string specifies the raw data for this subject (you may use wildcards) and the numbers in square brackets the series numbers for the EPI data. There should be as many of these are there are blocks, as specified in aap.acq_details.sessions and described above.

By default, MPRAGE structural and GRE_FIELDMAPPING fieldmap scans are automatically detected. This will lead to an error if for some reason you have collected more than one fieldmap or structural scan for a given subject. In this case you can specify those scans which should be ignored in a final optional parameter. For example, if you wished to ignore aborted structural scans with series numbers 2 and 3, you might type:

aap=aas_addsubject(aap, ‘*CBU0011\*’,[11],[2 3]);

<<
Anchor(s)>>
== Set specific parameters that you wish to differ from the defaults ==
Line 222: Line 195:
[[Anchor(s)]] <<Anchor(s)>>
Line 224: Line 197:
[[Anchor(s5.)]]
== 5. Getting ready to use AA ==
<<Anchor(s)>>
== Getting ready to use AA ==
Line 228: Line 201:
|| ||>> aa || || ||>> aa_ver1 ||
Line 233: Line 206:
[[Anchor(s5.)]]
== 5. Running an analysis ==
<<Anchor(s)>>
== Running an analysis ==
Line 237: Line 210:
[[Anchor(s5.)]]
== 5. Restarting an analysis ==
<<Anchor(s)>>
== Restarting an analysis ==
Line 241: Line 214:
[[Anchor(s5.)]]
== 5. How do I force an analysis to start all over again? ==
<<Anchor(s)>>
== How do I force an analysis to start all over again? ==
Line 249: Line 222:
|| ||cd /cbu/scratch2/rhodri.cusack/mystudydir || || ||cd /imaging/rhodri/mystudydir ||
Line 253: Line 226:
[[Anchor(s5.)]]
== 5. How do I force an analysis to start from a particular stage? ==
<<Anchor(s)>>
== How do I force an analysis to start from a particular stage? ==
Line 261: Line 234:
|| ||cd /cbu/scratch2/rhodri.cusack/mystudydir ||
|| ||cd W030511.ls1 ||
|| ||cd /imaging/rhodri.cusack/mystudydir ||
|| ||cd CBU060500 ||
Line 266: Line 239:
[[Anchor(s)]] <<Anchor(s)>>
Line 268: Line 241:
[[Anchor(s6.)]]
== 6. Check your data ==
<<Anchor(s)>>
== Check your data ==
Line 277: Line 250:
||<style="vertical-align: top;">''Name'' ||<style="vertical-align: top;">''File directory'' ||<style="vertical-align: top;">''Description'' ||
||<style="vertical-align: top;">diagnostic_aamod_ana4dto3d_rawmean ||<style="vertical-align: top;">Session ||<style="vertical-align: top;">raw mean as generated by ana4dto3d ||
||<style="vertical-align: top;">diagnostic_aamod_ana4dto3d_rawvar ||<style="vertical-align: top;">Session ||<style="vertical-align: top;">raw variance as generated by ana4dto3d ||
||<style="vertical-align: top;">diagnostic_aamod_tsdiffana ||<style="vertical-align: top;">Session ||<style="vertical-align: top;">output from tsdiffana ||
||<style="vertical-align: top;">diagnostic_aamod_realign ||<style="vertical-align: top;">Subject ||<style="vertical-align: top;">realignment display from SPM ||
||<style="vertical-align: top;">diagnostic_aamod_undist ||<style="vertical-align: top;">Subject ||<style="vertical-align: top;">evaluation of undistortion. Top pair of images are in distorted space and should be similar in shape and coregistered with each other. Left is distorted fieldmap magnitude, right is raw EPI. Bottom two images are in undistorted space and should be similar in shape and coregistered with each other, although not necessarily with the top two images. ||
||<style="vertical-align: top;">diagnostic_aamod_coreg ||<style="vertical-align: top;">Subject ||<style="vertical-align: top;">SPM output from coregistration of structural and undistorted EPI ||
||<style="vertical-align: top;">diagnostic_aamod_norm ||<style="vertical-align: top;">Subject ||<style="vertical-align: top;">SPM output from normalisation ||


[[Anchor(s6.)]]
== 6
. Changing the aa_user script ==
Be careful about changing the aa_user script after you’ve run part of an analysis. The problem with doing this is that if the changes you make would have affected the parts that have already been completed, you won’t be able to use the script to exactly recreate your data in future.

[[Anchor(s)]]
||<style="VERTICAL-ALIGN: top">''Name'' ||<style="VERTICAL-ALIGN: top">''File directory'' ||<style="VERTICAL-ALIGN: top">''Description'' ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_anato3d_rawmean ||<style="VERTICAL-ALIGN: top">Session ||<style="VERTICAL-ALIGN: top">raw mean as generated by anato3d ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_anato3d_rawvar ||<style="VERTICAL-ALIGN: top">Session ||<style="VERTICAL-ALIGN: top">raw variance as generated by anato3d ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_tsdiffana ||<style="VERTICAL-ALIGN: top">Session ||<style="VERTICAL-ALIGN: top">output from tsdiffana ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_realign ||<style="VERTICAL-ALIGN: top">Subject ||<style="VERTICAL-ALIGN: top">realignment display from SPM ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_undist ||<style="VERTICAL-ALIGN: top">Subject ||<style="VERTICAL-ALIGN: top">evaluation of undistortion. Top pair of images are in distorted space and should be similar in shape and coregistered with each other. Left is distorted fieldmap magnitude, right is raw EPI. Bottom two images are in undistorted space and should be similar in shape and coregistered with each other, although not necessarily with the top two images. ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_coreg ||<style="VERTICAL-ALIGN: top">Subject ||<style="VERTICAL-ALIGN: top">SPM output from coregistration of structural and undistorted EPI ||
||<style="VERTICAL-ALIGN: top">diagnostic_aamod_norm ||<style="VERTICAL-ALIGN: top">Subject ||<style="VERTICAL-ALIGN: top">SPM output from normalisation ||


<<Anchor(s)>>Rhodri Cusack, MRC CBU, Cambridge<<MailTo(rhodri DOT cusack AT mrc-cbu DOT cam DOT ac DOT uk)>>. Thank you to Matthew Brett, Jessica Grahn, Daniel Mitchell, Rik Henson & Matt Davis, who contributed to the code and this manual.



Overview

The components

The modules

aa has a modular design. Each module handles a single task, which may be peformed once per study, per subject or per session. All modules have a name that begins "aamod_" (e.g., aamod_realign). There are a few modules that process your input parameters or perform other setup tasks, which are run every time you launch an aa analysis. These are called "initialisation modules".

The engine

The engine (usually via the aa_doprocessing command) takes a description of the tasks you wish to perform, and then runs the appropriate modules. It also provides a number of helper subroutines to support the modules (beginning aas_), and also some useful utilities such as the aa_benchmark command to measure analysis times, and the aa_report tool to generate an HTML summary.

Specifying an analysis

The components of the aa system are arranged in a hierarchy. At the top recipes describe whole processing pipelines. They are made up of a selection of parameter sets, each of which defines a group related parameters. Finally, the individual parameters actually specify what happens. aa recipes begin with 'aarecipe_' and parameter sets 'aap_'

In your user script you must choose a recipe. If you wish, you may then override single parameters. Occasionally, you may also wish to override whole parameter sets from a recipe chosen.

The entire specification is contained in a single Matlab structure, usually called 'aap'. This has many elements, to store each of the paramter sets, and one that specifies the SPM default settings.

An overview of the different types of components is shown in this table:

Component

Description

Location of file

Expertise needed to write new ones

User script

Sets up a description of the analysis to be performed. Selects a recipe, adds study specific information, and changes any defaults

User's directory

Beginner

Recipes

A full description of the processing pipeline. This is implemented by choosing a group of parameter sets.

Centrally

Beginner/ Intermediate

Parameter sets

Groups of related parameters. There are five different basic types of parameter set

Centrally

Intermediate

Modules

Run individual stages of processing

Centrally

Some Matlab experience

Engine

Main automatic analysis engine, which contols module execution

Centrally

Advanced

The most important of these by far from the user’s point of view is the “User script”. The next section describes this.

User script

Overview

This specifies an analysis. Many studies can be analysed up to and including the stage of normalisation with changes to this alone. With some changes to the specificaiton of the experimental design in aamod_model_firstlevel, you may run all the way up to and including second level statistics.

There are sections to the user script:

Section

Probability you need to change it and when

1

Choosing a recipe

(0.2) If you use a non-standard acquisition sequence or wish to do a quite different type of analysis

2

Changing any of the parameter sets in the recipe

(0.1) If you wish to change a single parameter set controlling part of the automatic processing from what is specified in a recipe

3

Initialising using the parameter sets

(0.01) Usually never

Setting study specific details

(1.0) Always

Set any other parameters that need to differ from the defaults

(0. If you wish to change single parameters

||<style="vertical-align: top;">

Calling aa_doprocessing to do the processing

(0.01) Usually never

An example, which will process 3 subjects each with sessions up to and including normalisation is below:


% Automatic analysis

% User master script

% Rhodri Cusack MRC CBU Cambridge 200

% (1) RESET ALL PARAMETERS

aap=[];

% (2) ANALYSIS RECIPE

% General auto TR recipe; slice order Siemens product sequence default

aap=aarecipe_general_ver01(aap);

% (3) MODIFY STANDARD RECIPE MODULE SELECTION HERE IF YOU'D LIKE

  • % do this here

% ( GET ALL THE PARAMETERS FOR THIS RECIPE

aap=aa_init(aap);

% ( DEFINE STUDY SPECIFIC PARAMETERS

aap.options.aa_minver=1.0; % will only work on aa version 1.0 or above

  • % The study directory

aap.acq_details.root = '/home/rhodri/pvs/cbu';

  • % Add subjects and session numbers for EPI data

aap=aas_addsubject(aap,'*CBU0011/*',[11 12]);

aap=aas_addsubject(aap,'*CBU0012/*',[12 10]);

  • % Condition names for each session, must be same for all subjects

aap.acq_details.sessions={'mystery1','mystery2'};

  • % Number of dummy scans at the start of each session

aap.acq_details.numdummies=18;

% ( SET ANY OTHER PARAMETERS YOU WOULD LIKE TO BE DIFFERENT FROM THE DEFAULTS

% (7) SET ANY SPM DEFAULTS IF NEEDED

aap.spm.defaults.normalise.write.vox=[3 3 3];

% (8) DO PROCESSING

aa_doprocessing(aap);


The four sections you are mostly likely to need to change (1, 2, and are now discussed in turn.

NB: Be careful about changing the aa_user script after you’ve run part of an analysis. The problem with doing this is that if the changes you make would have affected the parts that have already been completed, you won’t be able to use the script to exactly recreate your data in future.

Choosing the recipe

These are chosen with the line

aap=[recipename](aap);

e.g., aap=aarecipe_general(aap);

An example recipe is shown below. Descriptions of the parameter sets are in the next section. A full list of recipes is on the AutomaticAnalysisManualReference page.

Name:

aarecipe_general

Description:

Standard automatic TR recipe

Parameter set choice:

Type

Parameter set

directory_conventions

aap_directory_conventions_ver00

options

aap_options_ver00

tasklist

aap_tasklist_cbudefault_ver00

spmanalysis

aap_spmanalysis_tr1p1_ver00

acq_details

aap_acq_details_ver00

Modify parameter set selection

A recipe comprises a description of the parameter sets that should be included. Once you’ve chosen a recipe you may override some of the different parameter sets. You would do this in stage 2 of the user script (see above) with a line like

aap.recipe.directory_conventions=’aap_directory_conventions_mynewstyle’

(NB: no ‘.m’ on end)

There are different types of parameter sets. A full list of the available parameter sets is given in the AutomaticAnalysisManualReference section.

Type

Description

directory_conventions

Specifies directory and file conventions, for example: raw data directory (by default /mridata/cbu)

options

General aa program options, for example: whether to automatically identify the field maps and structurals in the incoming dataset; whether to copy structurals to the central store

tasklist

The list of tasks to be performed (e.g., modules to be executed) for each study

spmanalysis

SPM & imaging analysis parameters, for example: TR & slice acquisition tim; smoothing FWHM; evolution time of fieldmaps

acq_details

Acquisition details. Several of the defaults are overridden in the user script, for example:
- study directory
- subject list

Setting your acquisition parameters

You always need to do this, to tell the system which files to analyse. The essential lines with explanation and notes are these:

aap.acq_details.root = '/cbu/scratch2/rhodri.cusack/newsimultaneous';

Specifies the directory where the processed study data are stored. This directory should exist before you run the script.

aap.acq_details.sessions={'ns1_block1','ns1_block2','ns2_passive','ns2_active'};

These are names of the blocks in your experiment. This must be the same for all subjects. Here, there were four blocks. I find it easiest to use intuitive names that describe the behavioural condition.

aap.acq_details.numdummies=18;

Number of dummy scans at the start of each session that need to be thrown away.

Too make it easy to see the correspondence between subject and session number, I now recommend subject names are added with the aas_addsubject command:

aap=aas_addsubject(aap, ‘*CBU0011\*’,[11]);

The full syntax of this command is in Error! Reference source not found., but the first string specifies the raw data for this subject (you may use wildcards) and the numbers in square brackets the series numbers for the EPI data. There should be as many of these are there are blocks, as specified in aap.acq_details.sessions and described above.

By default, MPRAGE structural and GRE_FIELDMAPPING fieldmap scans are automatically detected. This will lead to an error if for some reason you have collected more than one fieldmap or structural scan for a given subject. In this case you can specify those scans which should be ignored in a final optional parameter. For example, if you wished to ignore aborted structural scans with series numbers 2 and 3, you might type:

aap=aas_addsubject(aap, ‘*CBU0011\*’,[11],[2 3]);

Set specific parameters that you wish to differ from the defaults

Once you’ve set up the parameters using a recipe and any different parameter sets you’d like, there may still be one or two parameters that you need to change. You do this at this stage. For example, in the sample script, if my data were no longer in /mridata/cbu I would add the line:

aap.directory_conventions.rawdatadir='/imaging/rhodri/newsimultaneous';

A full list of parameters with descriptions is given in section Error! Reference source not found..

Set any SPM defaults

Any SPM defaults can be changed. You do this using lines like the following:

aap.spm.defaults.normalise.write.vox=[3 3 3];

The aap.spm.defaults structure gets copied into the GLOBAL “defaults” variable before running SPM functions.

Everyday tasks

Getting ready to use AA

Once you’ve started a Matlab/SPM session, type

>> aa_ver1

at the Matlab prompt to add the automatic analysis paths

Running an analysis

Once you’ve made your user script, just type its name to run it. When it starts to run, it does some checks, and so you may see some warnings. These give you advanced notice that your script may have problems at some stage

Restarting an analysis

To restart an analysis, just type the script name again. It will start from where it left off.

How do I force an analysis to start all over again?

Change to the study directory and delete the “done_aamod_studyinit” flag

Example

Type at UNIX prompt. When you run an analysis again it will redo the realignment stage and all stages after it for this subject.

cd /imaging/rhodri/mystudydir

rm done_aamod_studyinit

How do I force an analysis to start from a particular stage?

To track how far through the analysis it has got, the system writes small files that start with “done_...” and end with the module name. Where a module has to be executed once per study, the done_ file will be in the study directory. Where it has to be executed once per subject, it will be in the subject directory. Where it has to be done for every session, it will be in the individual session directories. If you delete one of these flags, then this stage and all others after it will be re-run. Note it isn’t always completely obvious whether a module is once-per-subject (e.g., realignment) or once-per-session (e.g., slice timing). See the Reference section 0 to check.

Example

Type at UNIX prompt. When you run an analysis again it will redo the realignment stage and all stages after it for this subject.

cd /imaging/rhodri.cusack/mystudydir

cd CBU060500

rm done_aamod_realign

Pitfalls - beware!

Check your data

Although the processing is automated, this doesn’t mean that things will never go wrong. Your data may have a problem – scanning glitches or excessive subject movement, for example – or there maybe something wrong with the analysis. Just as you would when doing it by hand, you should check your data at various stages.

Diagnostic JPEGs

One way of checking your data is to check through the images dumped in the analysed study, subject and block directories. These files begin with “diagnostic_aamod” end have a “.jpg” suffix. These are described in the table below.

Current output is all graphical, in the form of JPEG files. These may be viewed using a Windows graphics viewer, or with xv on unix. Examples are below

Name

File directory

Description

diagnostic_aamod_anato3d_rawmean

Session

raw mean as generated by anato3d

diagnostic_aamod_anato3d_rawvar

Session

raw variance as generated by anato3d

diagnostic_aamod_tsdiffana

Session

output from tsdiffana

diagnostic_aamod_realign

Subject

realignment display from SPM

diagnostic_aamod_undist

Subject

evaluation of undistortion. Top pair of images are in distorted space and should be similar in shape and coregistered with each other. Left is distorted fieldmap magnitude, right is raw EPI. Bottom two images are in undistorted space and should be similar in shape and coregistered with each other, although not necessarily with the top two images.

diagnostic_aamod_coreg

Subject

SPM output from coregistration of structural and undistorted EPI

diagnostic_aamod_norm

Subject

SPM output from normalisation

Rhodri Cusack, MRC CBU, Cambridge<rhodri DOT cusack AT mrc-cbu DOT cam DOT ac DOT uk>. Thank you to Matthew Brett, Jessica Grahn, Daniel Mitchell, Rik Henson & Matt Davis, who contributed to the code and this manual.

CbuImaging: AutomaticAnalysisManual (last edited 2013-03-07 21:24:14 by localhost)