tag:blogger.com,1999:blog-1405968300258104460.post774297710891531276..comments2024-03-29T08:33:38.267-04:00Comments on Andy's Brain Blog: SPM: Setting the Origin and Normalization (Feat. Chad)Andrew Jahnhttp://www.blogger.com/profile/16435706598096921650noreply@blogger.comBlogger39125tag:blogger.com,1999:blog-1405968300258104460.post-12211505790770084382020-04-22T11:46:30.658-04:002020-04-22T11:46:30.658-04:00Hi Andrew,
I actually don't know exactly what...Hi Andrew,<br /><br />I actually don't know exactly what those mean, but your intuition is probably correct. I don't know if there's a downside to using more iterations, aside from longer computation time; this should be relatively simple to check though by comparing it with a high versus a low number of iterations.<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-28508924627604922342020-04-22T11:27:47.273-04:002020-04-22T11:27:47.273-04:00Hey Emmanu,
Unfortunately I don't know of an ...Hey Emmanu,<br /><br />Unfortunately I don't know of an automatic tool to do it; you'll need to do it manually. I would only do it for the subjects that seem to need it, though; i.e., if the origins of the functional and anatomical images are very far apart.<br /><br />By the way, an updated tutorial has been made here: https://andysbrainbook.readthedocs.io/en/latest/SPM/SPM_Overview.html<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-9148426426996363932020-04-17T09:00:41.577-04:002020-04-17T09:00:41.577-04:00Now I have managed to use the tool as you explain ...Now I have managed to use the tool as you explain (it only took me the whole day! :D). Now I wonder if there is a way to do this via console using Matlab functions instead of using a display. I have been searching in the SPM12 folder but couldn't find anything.Emmanuhttps://www.blogger.com/profile/17135806221839427555noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-344454928415605772020-04-17T01:16:06.204-04:002020-04-17T01:16:06.204-04:00Hi Andy, I have a NIFTI image which is not in a st...Hi Andy, I have a NIFTI image which is not in a standard MNI space (I guess it is in native space). How could I normalize it to the standard space? Is there a tool or code I could use for this purpose? I am attempting to view this native image in third-party software, but it wouldn't let me unless it is in MNI space.Emmanuhttps://www.blogger.com/profile/17135806221839427555noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-15273919065530368252020-04-15T17:40:15.251-04:002020-04-15T17:40:15.251-04:00Hi Andy.
I work with mouse fMRI and I'm tryin...Hi Andy.<br /><br />I work with mouse fMRI and I'm trying to use SPM12 to normalize my data to the Allen Atlas. I'm using the old normalize function and was wondering if you could give me an explanation of what the nonlinear freq cutoff and regularization means? I assume iterations means how many times it tries to match (so more would be better in a sense?). Thanks for all your content. Made learning fMRI processing very easy even in mouse fMRI.Andrewnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-84045687217323117722020-03-31T15:49:03.780-04:002020-03-31T15:49:03.780-04:00Hi there,
No, you won't need to reset the ori...Hi there,<br /><br />No, you won't need to reset the origin; that is done mainly to help the coregistration step.<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-82949869746852962352020-03-24T10:54:35.269-04:002020-03-24T10:54:35.269-04:00Hey there,
So I've set my origin at the anter...Hey there, <br />So I've set my origin at the anterior commissure, and then run co-registration. <br />Now i'm ready to normalise the data.<br /><br />However - I've noticed that if I display the T1s and click on "origin" it is no longer the anterior commissure, which makes some sense since the images have been slid to match the functional scans.<br /><br />However, I am confused. Should I re-adjust the origin to the commissure before warping to MNI space?<br /><br />Thanks so much for all your content. hugely helpful.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-10810430238072532302020-01-15T18:03:00.865-05:002020-01-15T18:03:00.865-05:00Hello Anonymous, I have made a script to ease/auto...Hello Anonymous, I have made a script to ease/automate reorientation and coregistration. If you don't have a T1, you can coregister your functionals on the provided template, or use SPM's one. It's suboptimal compared to having a structural per subject, but it should work.<br /><br />https://github.com/lrq3000/spm_auto_reorient_coregister<br /><br />Now the biggest problem you will face is not reorientation and coregistration of fmri, since you can use a template, but rather the fact that segmentation will have to be done on the functional data, which is suboptimal since functional images have very low resolution (compared to structural at least). Segmentation is particularly useful for denoising, so essentially you won't be able to denoise. What you can try to do is again to segment from a template (or rather directly use SPM's tissue probability maps, just threshold them to make binary maps) and feed that to your ICA or CompCor denoising tool. But do note that this is very suboptimal, if you can reacquire the subjects with structural images (or acquire a new dataset), it would be far better. But if you don't have any other choices, you can give this template-based approach a try.lrq3000https://www.blogger.com/profile/14275907715478948968noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-45942479866118283212020-01-15T05:33:33.466-05:002020-01-15T05:33:33.466-05:00Hi Andy, if I don't have structural data in fM...Hi Andy, if I don't have structural data in fMRI, should I use the Old normalization or is there a more accurate method? thanksAnonymoushttps://www.blogger.com/profile/05961095768097452360noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-6963608703648370792018-06-15T12:33:47.027-04:002018-06-15T12:33:47.027-04:00Hi Andy,
I'm normalizing my data to the segmen...Hi Andy,<br />I'm normalizing my data to the segmented Cincinnati pediatric template. Should I change the bounding box values? What values should I use, if not the SPM default?<br />Thank you,<br />YaelAnonymoushttps://www.blogger.com/profile/11874196186793415873noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-25333173889267634612018-05-10T14:55:46.575-04:002018-05-10T14:55:46.575-04:00This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/02850382881110936144noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-59927788593313768752018-04-23T16:44:53.145-04:002018-04-23T16:44:53.145-04:00Hi Andy,
I'm a noob and I need help.
I wrot...Hi Andy,<br /><br />I'm a noob and I need help. <br /> I wrote the following script using an SPM batch to normalise data to MNI space. I use pre-existing y-files and loop over 77 patiënts. When I run the script, it does run but it says the following: Item 'Deformation Field', field 'val': Number of matching files larger than max allowed, keeping 1/77 file After running 'normalise: write' it gives an error: 'Index exceeds matrix dimensions'<br /><br />It looks like it only uses 1 of 77 y-files for all 77 patients, which results in faulty normalization. Even though the path_yfile is a 77x1 cell and all other variables seem well defined looking at the workspace.<br /><br />the script:<br />List of open inputs<br />% Normalise: Write: Deformation Field - cfg_files<br />% Normalise: Write: Images to Write - cfg_files<br />wd='/Data/users/ano/verbgen_seg/';<br />ID_CODES=dir([wd '*.MRI.1']);<br />N=length(ID_CODES);<br />path_yfile = cell(N, 1); % predefines the size of the matrix<br />Images=cell(N, 1); <br />for i = 1:length(ID_CODES) % Loop over patients<br />dp=char(strcat('/Data/users/ano/verbgen_seg/',ID_CODES(i).name,'/Images/')); <br />d=dir([dp '*T1W*']);<br />d1=d(1);<br />Images(i, 1)= {char(strcat(dp, d1.name))}; <br />dp=char(strcat('/Data/users/ano/verbgen_seg/', ID_CODES(i).name,'/Images/'));<br />d=dir([dp,'*y_*']);<br />path_yfile(i, 1) = {char(strcat(dp, d.name))};<br />end <br />for i=1:length(ID_CODES)<br />nrun = 1; % enter the number of runs here<br />jobfile = {'/Data/users/ano/SPM_analysis_GK/normaliseseg_job_test.m'};<br />jobs = repmat(jobfile, 1, nrun);<br />inputs = cell(2, nrun);<br />for crun = 1:nrun<br /> inputs{1, crun} = path_yfile(:, i); % Normalise: Write: Deformation Field - cfg_files<br /> inputs{2, crun} = Images(:, i); % Normalise: Write: Images to Write - cfg_files<br />end<br />spm('defaults', 'FMRI');<br />spm_jobman('run', jobs, inputs{:});<br />endAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-12826431556834010872017-12-19T19:08:02.260-05:002017-12-19T19:08:02.260-05:00Hey Abel,
See spm_normalise for that; I think the...Hey Abel,<br /><br />See spm_normalise for that; I think the help should be straightforward.<br /><br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-39783103533023863982017-11-28T13:19:55.518-05:002017-11-28T13:19:55.518-05:00Thanks for answering. I have not used "job&qu...Thanks for answering. I have not used "job" files until now, but what I am doing is write the script using only the purely functions. For example: in motion correction I used spm_realign.mat and spm_reslice.mat; in slice-timing correction I used spm_slice_timing; for smoothing spm_smooth.mat; etc..) My second question: Is there any function or group of functions (like mentioned above) to perform normalization? <br /><br />Thank you again,<br /><br />Abel GonzálezAnonymoushttps://www.blogger.com/profile/02680054949020281660noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-17561586777386109582017-11-24T15:53:34.491-05:002017-11-24T15:53:34.491-05:00Hey Abel,
Open up Normalise (Estimate and Write) ...Hey Abel,<br /><br />Open up Normalise (Estimate and Write) from the GUI, and fill it in like you would when analyzing a single subject. Once you've filled in all the fields, click on File -> Save Batch and Script. This will create a "job" file containing the Matlab code you need to submit to spm_jobman to automate it.<br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-69592941885358284542017-11-23T10:51:28.058-05:002017-11-23T10:51:28.058-05:00Hi Andrew,
Your videos and explanations are so h...Hi Andrew, <br /><br />Your videos and explanations are so helpful. I'm working with SPM, but I'm making all the preprocessing steps using the command line and I'm doing my own scripts. My question is... How I can do normalization using the command line? I cannot find the functions that perform normalization. <br /><br />Thanks!<br /><br />Abel GonzálezAnonymoushttps://www.blogger.com/profile/02680054949020281660noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-60216072391382071682017-11-22T16:19:21.156-05:002017-11-22T16:19:21.156-05:00Hi Nick,
You can do this by using an image calcul...Hi Nick,<br /><br />You can do this by using an image calculator. In the case of SPM, I use spm_imcalc_ui:<br /><br />P1 = '/path/to/image.nii';<br />P2 = '/path/to/image2.nii';<br /><br />spm_imalc_ui([P1; P2], 'average.nii', '(i1+i2)/2'<br /><br /><br />You can expand this to include as many image as you have. Note that if you are taking the average of your normalized images, then the output will also be in normalized space; alternatively, you could register all of your anatomicals to a reference anatomical (e.g., one chosen at random) and then take the average of the registered anatomicals. However, this would not be in normalized space, which would preclude direct comparisons across studies.<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-84747060001831756842017-11-20T18:20:39.546-05:002017-11-20T18:20:39.546-05:00Hi Andy,
Have you ever built a study specific tem...Hi Andy,<br /><br />Have you ever built a study specific template? I have a considerable amount of subjects (around 115) and I would like to make a template out of my sample. Do you have any idea how to perform this?<br /><br />Best regards,Anonymoushttps://www.blogger.com/profile/14942676372487371925noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-9836581447561540792017-10-10T07:16:35.360-04:002017-10-10T07:16:35.360-04:00For visualizing data, why dont you use a diagram t...For visualizing data, why dont you use a <a href="http://creately.com" rel="nofollow">diagram tool</a> which you can input data of each set and get the output illustration.Evanhttps://www.blogger.com/profile/01134034541170679170noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-72278829123532460562017-08-27T13:14:28.974-04:002017-08-27T13:14:28.974-04:00Hey there,
I don't have experience with fetal...Hey there,<br /><br />I don't have experience with fetal brains, so I can't say; it would be much safer to have a fetal brain template to warp to, as many of the steps you outline can introduce a lot of distortions (and normalization already distorts the image to some degree). I would ask around to see if anyone has such a template (although I don't know where I would start). It may be worth doing the analyses in each subjects' individual space, if you only have a few of them.<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-80195137858619209012017-08-11T02:55:13.437-04:002017-08-11T02:55:13.437-04:00Hi Andy,
thank you for your vedios which help me ...Hi Andy, <br />thank you for your vedios which help me a lot. right now, i am processing the fetal brain data with the combination of FSL and AFNI. I have been quite confused about the normalization in 2 aspects:<br />1, the fatal anatomic image is seriously affected by motion, so i decided to register the functional image to the EPI template which i 'steal' from the SPM12 directly. Do i need to reorient the functional volumes? It is so hard to secify the AC PC in the fatal functional brain.<br />2.The fetal brain i extracted from the womb image is so small that it can hardly register to the template. Then i scale it manully with a global factor , is it Ok? What's more, i can hardly evaluate the results of registration as the image is too blur. I can't figure out which action is better when comparing flirt with fnirt.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-60184915386248052572017-05-05T16:21:38.966-04:002017-05-05T16:21:38.966-04:00Hey there,
Which software are you using? I don...Hey there,<br /><br />Which software are you using? I don't know how to do that with SPM, but here's how to do it with FSL:<br /><br />1. If you've run the preprocessing of your functional data to a standardized space, in the "reg" folder you will find many transformations matrices - not only the transformation matrix to bring the functional data to standardized space, but also a matrix to reverse the process and bring standardized space to the subject's native space. You can find the latter in standard2example_func.mat.<br /><br />2. Use flirt to transform the ROI to subject space: flirt -in ROI_StandardizedSpace.nii.gz -ref example_func.nii.gz -init standard2example_func.mat -applyxfm -out ROI_SubjectSpace.nii.gz<br /><br /><br />Let me know if you need to do this for AFNI, and I'll give you the code for that.<br /><br />Best,<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-24135815805785056332017-05-04T08:36:06.130-04:002017-05-04T08:36:06.130-04:00Hi Andy, can I "de-normalize" an image? ...Hi Andy, can I "de-normalize" an image? If I found an ROI in an normalized image but want to know how big this ROI is in non-normalized image? Can I return the process of nromalization? ThanksAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-11432978809368168942017-03-08T15:26:56.408-05:002017-03-08T15:26:56.408-05:00Hi Alice,
If you want to use the old method of no...Hi Alice,<br /><br />If you want to use the old method of normalization, from the GUI you can select Batch, then from the dropdown menu select SPM -> Tools -> Old Normalise. This will allow you to use the T1.nii image as a template.<br /><br />-AndyAndrew Jahnhttps://www.blogger.com/profile/16435706598096921650noreply@blogger.comtag:blogger.com,1999:blog-1405968300258104460.post-78037004804833657402017-03-02T08:28:10.617-05:002017-03-02T08:28:10.617-05:00Hi,
I am attempting to analyse EEG data using Mat...Hi, <br />I am attempting to analyse EEG data using MatLab and an extension known as EEGLAB. In order to carry out DIPFIT in this programme I need to first convert the fMRI images, which were collected as the same time as the EEG data, from MR head images to the MNI brain template. I am using SPM12 to do so, I understand your video tutorials use an older version and I have tried to follow them but am struggling to understand what template SPM12 uses as there is no option to select T1 as your template image when normalising images. Do you have any advice?<br />ThanksAnonymoushttps://www.blogger.com/profile/17222492527067619347noreply@blogger.com