tag:blogger.com,1999:blog-1405968300258104460.post6445730998753397663..comments2024-03-27T01:18:24.341-04:00Comments on Andy's Brain Blog: SPM RealignAndrew Jahnhttp://www.blogger.com/profile/16435706598096921650noreply@blogger.comBlogger47125tag:blogger.com,1999:blog-1405968300258104460.post-28149256095920340092020-06-01T01:31:05.037-04:002020-06-01T01:31:05.037-04:00Hi Andy,
I am confused in using SPM12 for realign...Hi Andy,<br /><br />I am confused in using SPM12 for realignment. I have performed several MRI scans. Each scan consists of two separate volumes: A magnitude image and a phase image. What I would like to do is to realign the phase image, using the magnitude image as the realignment parameter. How could I do it? <br /><br />I have tried to run Realign(Estimate) on all magnitude image first, but then if I reslice the phase image, it all looks weird. Look forward to your reply. Edenhttps://www.blogger.com/profile/04396112254180538927noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-2139060315165036242020-05-04T11:24:44.861-04:002020-05-04T11:24:44.861-04:00Hi Bram,
How much do the motion parameters differ...Hi Bram,<br /><br />How much do the motion parameters differ? If it's on the order of thousandths of a millimeter, it may be due to some kind of interpolation that is performed when the images are rotated (e.g., with zero-padding). If the difference in the motion parameters is very small, I wouldn't think it would affect ART that much.<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-9336531358582798742020-05-04T11:18:48.004-04:002020-05-04T11:18:48.004-04:00Hi Harshan,
I don't think SPM has the ability...Hi Harshan,<br /><br />I don't think SPM has the ability to do affine registration for coregistration, since any zooms or shears would distort the images of what are supposed to be the same brain; the normalization module, however, seems to use affine registration. For nonlinear options, you could check out something like the advanced normalization tools suite (ANTs).<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-69942896267238465542020-04-24T11:22:37.151-04:002020-04-24T11:22:37.151-04:00Hi Emmanu,
Realignment is the moving of each volu...Hi Emmanu,<br /><br />Realignment is the moving of each volume to match a reference image - usually the first volume, or an average of all the volumes. Since this realignment can shift the entire volume's field of view, the images also need to be resliced in order to standardize the voxel resolution and field of view dimensions.<br /><br />Regarding your second question, even after realignment there might be variations in the BOLD signal in each voxel due to movement. The motion regressors will "load" onto this variance, removing it from the actual signal that is caused by your task.<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-71739472185155857882020-04-14T02:34:13.759-04:002020-04-14T02:34:13.759-04:00Hi! Thanks for your post.
I am very confused about...Hi! Thanks for your post.<br />I am very confused about the terminology: RESLICE REALIGN... are these the same thing? If so, as I see in many manuals, why do they have their own commands? They must do different things.<br /><br />I am confused because we seem to remove the variance of head motion twice:<br />1) realignment<br />2) motion regression (that we can add as covariates; some packages as DPABI do realignment and motion regression during the preprocessing).<br /><br />Do these both steps accomplish the same? Why do some people do both and some just realignment? I would have thought that regressing out the motion parameters once the data has been already... controlled for head motion, would be wrong.<br /><br />Thanks for your responses, <br />Emmanu—A beginner—very confused.Emmanuhttps://www.blogger.com/profile/17135806221839427555noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-26922782271760682002020-02-14T07:03:39.393-05:002020-02-14T07:03:39.393-05:00Hi Andy,
First I would like to thank you for your...Hi Andy,<br /><br />First I would like to thank you for your posts. It seems that every time I encounter a problem, I am most likely to find the solution on your website!<br /><br />I do have a question regarding realigment in SPM. In my preprocessing pipeline I started with slice time correction & motion correction. Several steps later, after distortion correction, I found myself forced to do a (minimal) manual reorientation as images no longer alligned well enough with the SPM template T2 to do normalization. I expected this not to impact my realignment parameters. To test my theory I ran realignment in a single subject: one original scan, and one slightly reoriented (not motion corrected previously). It turns out that the parameters do differ.<br /><br />My questions are<br />1) Why are the motion parameters affected by reorientation? I thought the images would just be realigned with the first image, hence it wouldn't matter how the images are oriented?<br /><br />2) depending on the first question/answer: say I would use the motion parameters to run ART, how would the reorientation (and altered motion parameters) affect this processing step?<br /><br />Many thanks in advance.<br />Best regards,<br />BramBramnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-1332829361324076782020-01-30T11:33:58.820-05:002020-01-30T11:33:58.820-05:00Hi Andy,
Is there any tool/coomand in spm12 which...Hi Andy,<br /><br />Is there any tool/coomand in spm12 which could perform affine registration? Your help would be much appreciated. <br /><br />regards<br />Harshan RaviHarshan Ravihttps://www.blogger.com/profile/07962295136717485900noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-83542752643974235642020-01-15T04:24:14.508-05:002020-01-15T04:24:14.508-05:00Hi,
Please, can you explain me the difference betw...Hi,<br />Please, can you explain me the difference between realignment & Unwarp and Realignment: estimate & reslice?<br />Many thanks in advance!<br />Soren Eseninhttps://www.blogger.com/profile/04227141392558619199noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-77406838004498837792019-07-29T07:59:56.795-04:002019-07-29T07:59:56.795-04:00I read something about this online. From what I un...I read something about this online. From what I understood, it comes down to the following (until a more knowledgable person confirms or denies, take it with a grain of salt when it comes to deciding how to analyse): depending on your model (i.e., GLM or more complicated) it may still be necessary and/or beneficial to add the motion parameters as regressors. This is because during shimming (or at least preparation directly before scanning) the field is set to be optimally homogeneous in the slices you selected based on your localiser (this may be an inaccurate way of putting it, but at least the field within the selected slices is optimised). From what I understand, adding the motion parameters as a regressor regresses away the effect that is caused by the brain moving away slightly from that optimised area. Thus, even though you may visually confirm that the slices are realigned after motion correction, the fact that the brain moved away from the optimised area (even though possibly only slightly) causes some noise, and can be regressed away by adding the motion parameters as a regressor.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-38719656462817121472019-04-05T10:59:00.087-04:002019-04-05T10:59:00.087-04:00Thanks for the post.
I have a question: After the ...Thanks for the post.<br />I have a question: After the motion correction is done there are two output files: calculated motion parameters rp_*.txt and functional images, u_*.nii. Is the output u_*.nii image free from the motion noise? I.e., can I treat the image as motion-free if doing something out of SPM with it? For example if I want to load it manually into matlab, build timecource of a certain voxel, etc, I do not need motion parameters, right? If that so, then why do I need to include motion parameters as regressors in the 1st level analysis, after preprocessing?<br /><br />Best regards,<br />IgorIgor Izyurovhttps://www.blogger.com/profile/02051249773764727226noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-78020018321047363612018-11-16T23:16:15.069-05:002018-11-16T23:16:15.069-05:00Hi Andy,
Thank you very much for all the great inf...Hi Andy,<br />Thank you very much for all the great information here. But I think the last three parameters in the rp_*.txt file are actually in radians, not degrees in SPM12 (and perhaps previous versions too). Because what it writes in the rp_*.txt file is the output from spm_imatrix.m (line 538 in spm_realign.m), and this function returns rotation parameters in radians.<br /><br />The plot that spm_realign.m creates shows rotations in degrees by multiplying 180/pi (line 517 in spm_realign.m).<br /><br />It's not a serious problem when just covarying motion parameters, but framewise displacement could be inaccurate (underestimating rotational displacement) if the unit is assumed to be a degree.Solhttps://www.blogger.com/profile/16837957531228449833noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-71182058991767857662018-07-19T04:13:04.662-04:002018-07-19T04:13:04.662-04:00I had the same issue when running batch scripts. H...I had the same issue when running batch scripts. How I get the summary graphic window is to open up the SPM GUI before running the batch script. Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-61590674055735386592018-02-15T06:49:31.044-05:002018-02-15T06:49:31.044-05:00(forgot to add that I am using 4d images)(forgot to add that I am using 4d images)MMMhttps://www.blogger.com/profile/14041235275823795191noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-12824282864237979432018-02-15T06:44:11.762-05:002018-02-15T06:44:11.762-05:00Thank you in advance for help!!! Thank you in advance for help!!! MMMhttps://www.blogger.com/profile/14041235275823795191noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-34135778550613035742018-02-15T06:43:49.580-05:002018-02-15T06:43:49.580-05:00Hi, I am doing my realignment, and I successfully ...Hi, I am doing my realignment, and I successfully obtain my r prefixed files, but SPM does not display the image realignment summary in the graphic window as it should.... I would like to see the graphs for translation and rotation, and I have no clue how to get them? (I am using the SPM 12). MMMhttps://www.blogger.com/profile/14041235275823795191noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-33000442115991344392017-12-21T16:53:56.315-05:002017-12-21T16:53:56.315-05:00Hi Andy,
Thanks for your concern/desire to track...Hi Andy, <br /><br />Thanks for your concern/desire to track down and destroy my problem. I seem to have gotten it working? <br /><br />I omitted the line: scans02 = [cellstr(c); cellstr(d)];<br /><br />and I rewrote this line as: <br />matlabbatch{1}.spm.spatial.realign.estwrite.data = {<br /> cellstr(c)<br /> cellstr(d)<br /> };<br /><br />Now, this code produces the resliced ("ra" prefix) files for both runs and a separate movement parameters ("rp*.txt") file for each run. <br /><br />I still only get one mean functional image file, which I believe is correct when you have two sessions? This provides a mean of all volumes from both sessions? This at least makes more sense to me in that I only have one mean image that encompasses both sessions to use during coregistration. Does this seem right? <br /><br />Thanks for your help! <br />-Kathleen Kathleen H.noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-34357441611296711422017-12-19T19:33:31.446-05:002017-12-19T19:33:31.446-05:00Hey Kathleen, I'll take a look into this. I...Hey Kathleen, I'll take a look into this. I'm on the road right now, so it may be a couple of days, but we will track this problem down and destroy it.<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-5661437194546226032017-12-12T21:20:59.922-05:002017-12-12T21:20:59.922-05:00Hi Andy,
Thanks very much for your helpful expla...Hi Andy, <br /><br />Thanks very much for your helpful explanations of everything. With regards to realignment, I have put together a batch file for preprocessing my data. In this case, I have two "runs" per subjects, which I inputted as two "sessions" in slice time correction. Now, I want to do realign/reslice. This is the code that my for-loop runs through for each person (and each time point, as this is a longitudinal study): <br /><br />data_path = ['Research Projects/flight/02_Nifti/',subjID,'/',timepoint,'/combined_L_R'];<br /><br />c = spm_select('ExtFPList', fullfile(data_path),'^a.*005a001\.nii$',1:66);<br />d = spm_select('ExtFPList', fullfile(data_path),'^a.*007a001\.nii$',1:66);<br /><br />scans02 = [cellstr(c); cellstr(d)];<br /><br />clear matlabbatch<br /><br />%ERROR: I'm only getting 1 realignment params file here. <br />matlabbatch{1}.spm.spatial.realign.estwrite.data = {scans02};<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.quality = 0.9;<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.sep = 4;<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.fwhm = 5;<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.rtm = 1; %1 = mean; 0 = first <br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.interp = 2;<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.wrap = [0 0 0];<br />matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.weight = '';<br />matlabbatch{1}.spm.spatial.realign.estwrite.roptions.which = [2 1];<br />matlabbatch{1}.spm.spatial.realign.estwrite.roptions.interp = 4;<br />matlabbatch{1}.spm.spatial.realign.estwrite.roptions.wrap = [0 0 0];<br />matlabbatch{1}.spm.spatial.realign.estwrite.roptions.mask = 1;<br />matlabbatch{1}.spm.spatial.realign.estwrite.roptions.prefix = 'r';<br /><br />spm_jobman('run',matlabbatch);<br /><br /><br />I am totally confused--this code produces a resliced "ra"-prefix file for each of the two runs and one mean functional image. However, it only produces one "rp.txt" file. The rp file seems to include the movement parameters for both the first and second runs... <br /><br />I also get a file: a.mat for both the 005a001 and 007a001 runs... I am not sure what this is, as I have never gotten this from realign/reslice before? <br /><br />What is most confusing to me is that, when I run what I think is exactly the same code from the GUI (setting the first run as session 1 and the second run as session 2), I get a separate movement parameters file for the two runs. Do you have any insight into what might be going on here? <br />Kathleennoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-81601034782665924282017-09-02T19:06:02.757-04:002017-09-02T19:06:02.757-04:00Got it, thanks a lot Andy. Got it, thanks a lot Andy. anthonyhttps://www.blogger.com/profile/01259983131627238788noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-36923611939322349152017-08-27T13:11:50.523-04:002017-08-27T13:11:50.523-04:00Hey there,
My understanding is that SPM first ali...Hey there,<br /><br />My understanding is that SPM first aligns the images to the first image of the first volume, while creating a mean image; then it does a second pass where the images are aligned to the mean. I'm not sure what the advantage is of this over just aligning everything to the mean, though. (See this thread: https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=spm;5dfedb11.0801)<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-75085829031561511622017-08-16T01:49:27.149-04:002017-08-16T01:49:27.149-04:00Hi Andy,
I have a question concerning an addition...Hi Andy,<br /><br />I have a question concerning an additional option in spm 12: spm12 now has an option under Num Passes "Register to mean". I selected that option and the rp_.txt file is still a row of zeroes for the first volume of the first run. <br /><br />I am assuming SPM is registering the first volume of each session to the first volume of the first run. Subsequently, each volume is is then registered to the mean image within each session? I am confused about what this "Register to mean" option is doing. Thanks!<br /><br />anthonyhttps://www.blogger.com/profile/01259983131627238788noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-28512115784643566012017-03-23T11:40:30.365-04:002017-03-23T11:40:30.365-04:00OK. Thanks very much Andy.OK. Thanks very much Andy.Anonymoushttps://www.blogger.com/profile/11631586205948424176noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-40534864582555497542017-03-23T10:47:48.193-04:002017-03-23T10:47:48.193-04:00Hey Steve, it's difficult to know without seei...Hey Steve, it's difficult to know without seeing what's on your computer, but if the motion is calculated relative to the very first scan in the series then I think you should be OK. The only issue is, I don't know how it would affect your parameter estimates if the scans are entered as a block for each run, and the motion regressors are a single column across all the runs. I'm not sure. I believe AFNI puts in the motion regressors as a single column, but maybe the mechanics of the software packages are different.<br /><br />It's also debatable about when you should include motion regressors. For subjects who move quite a bit (say, more than the size of a voxel; e.g., 2-3mm) motion regressors may be able to explain any variance associated with their motion. Motion regressors could also be useful if you have a study where motion may be confounded with a condition - for example, moving in response to a shock.<br /><br /><br />Best of luck,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-36959723486817520912017-03-21T11:41:18.654-04:002017-03-21T11:41:18.654-04:00easy for a user such as myself to mess up.easy for a user such as myself to mess up.Anonymoushttps://www.blogger.com/profile/11631586205948424176noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-48411854669850310082017-03-21T11:40:40.930-04:002017-03-21T11:40:40.930-04:00Hi Andy,
Great to hear from you. Basically yes, i...Hi Andy,<br /><br />Great to hear from you. Basically yes, it's concatenated, but I didn't do it on my own. I hope i can go with your conclusion in the second paragraph. <br /><br />I used 'named file selector' to pick my (six) functional runs, ran it thru preprocessing (VDM, realign&unwarping, slice time, coreg, etc.,) and then 'file set split' the results. I now have 6 function runs to submit to 1st level model specification. However, realign&unwarp made just (1) rp_*.txt movt parameter file. It's as long as the total number of images from the six runs. first row is zeros, no more zeros after that. I am trusting SPM to keep track of the runs and dependencies in the batch but it seems fairly brittle and Anonymoushttps://www.blogger.com/profile/11631586205948424176noreply@blogger.com