Hello Jan, <br><br>When calling volumesegment, I specified 'ctf' as the coordinate system. The function I wrote to call volumesegment and prepare_singleshell for each subject and save the results is pasted below, with a couple of comments added for clarity.<br>
Over the weekend I tried specifying the coordinate system in the call to ft_volumenormalise as 'ctf' rather than 'spm', and commented out all the lines that said cfg.spmversion = 'spm8'; before calling a function. However, that created worse results, as each plot involved stripes of activation and empty voxels, suggesting that 'ctf' was not the correct coordinate system to specify.<br>
<br>Thanks for the attached script. Looking in that the comments in that, I suspect that the solution to my problems will be to specify my filetype as nifti_img rather than nifti. I'll let you know how that goes.<br>
<br>
Jen<br><br>------------------------------------------------------------------------------------------------------------<br>% the variable subj is simply a string consisting of a subject number (e.g. 's05') which can be a folder name or part of a filename<br>
function [vol mri segmentedmri segmentedmriF]=call_volume_segment_function_spm8(subj)<br>cfg.spmversion = 'spm8';<br>cfg.template = '/home/woodwardlab/spm8/templates/EPI.nii';<br>%cfg.template='/home/common/matlab/spm2/templates/T1.mnc'; <br>
<a href="http://cfg.name">cfg.name</a>=[subj '_volseg'];<br>cfg.write='yes';<br>cfg.smooth='no'; <br>cfg.coordinates='ctf'; <br>mri=read_mri([subj '/mri/' subj 'head.mri']); % made with CTF mriConverter and mriViewer software, after fiducials were marked<br>
segmentedmri = volumesegment(cfg, mri);<br>segmentedmriF = segmentedmri;<br>segmentedmriF.gray = flipdim(flipdim(flipdim(segmentedmriF.gray,3),2),1);<br>segmentedmriF.white = flipdim(flipdim(flipdim(segmentedmriF.white,3),2),1);<br>
segmentedmriF.csf = flipdim(flipdim(flipdim(segmentedmriF.csf,3),2),1);<br>segmentedmriF.transform = mri.transform;<br>segmentedmriF.anatomy = mri.anatomy;<br>cfg = [];<br>cfg.spmversion = 'spm8';<br>vol = prepare_singleshell(cfg, segmentedmriF);<br>
eval(['save ' subj '/meg/mrisegmented.mat mri segmentedmri segmentedmriF vol'])<br><br><br><br><div class="gmail_quote">On Sat, Feb 26, 2011 at 5:26 AM, jan-mathijs schoffelen <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;">Dear Jen,<div><br></div><div>I do not manage to reproduce your issue, when only focussing on the ft_volumewrite and visualization part of your pipeline. See attached script, and yet an updated version of ft_volumewrite which you need to (hopefully) draw the same conclusion as I did.</div>
<div>Yet, I only now realize that your question may pertain to the entire pipeline. It could be that something is going wrong there. </div><div>I only see now that in the part of your script of which you reported that it gave 'good' results, you specify cfg.coordinates = 'ctf' before calling ft_volumenormalise. I assume this is correct, because the coordinate system your source-reconstructed data lives in, is according to the CTF-convention, and not according to the SPM-convention. On the other hand, the template for the spatial normalization lives in the SPM-coordinate system. In order for the spatial normalization to work OK, Fieldtrip tries to convert from one coordinate system to the other (once again, this is appropriate behaviour), before doing the actual normalization. It seems that at least in the script you sent along, in the final (not working version), you specified cfg.coordinates = 'spm' prior to calling ft_volumenormalise. This is probably wrong.</div>
<div>Another important point that should be mentioned, is that the coordinate systems in which the functional data and the anatomical data live should be the same for the ft_sourceinterpolate to make sense. In other words, if your source reconstructed images are defined on a 3D grid of positions in CTF-space, the mri.transform of your anatomy should describe a transformation from voxel to CTF-space.</div>
<div>I think you may want to revisit step by step this part of the pipeline; I don't think the problem lies in the writing.</div><div>A final possibility of course is that Mricron is misbehaving...</div><div><br></div>
<div>Best,</div><div><br></div><font color="#888888"><div>Jan-Mathijs</div><div><br></div><div><br></div><div><br></div><div></div><span></span></font></div><br><div style="word-wrap: break-word;"><span></span><div></div>
<span></span></div><br><div style="word-wrap: break-word;"><span></span><div></div><div><br><div><div>On Feb 25, 2011, at 9:44 PM, Jen Whitman wrote:</div><br><blockquote type="cite">Hi Jan,<br><br>I tried re-running the analysis with the new script you sent me, and the latest version of fieldtrip (since I needed ft_get_opt as well), but the spm8 images being written are still producing flawed results. It's the same problem as I mentioned briefly in my previous post. I am not getting any error messages when writing these images. Rather, my problem is that the spm8 and spm2 results from the same data ought to be identical when viewed in mricron, but they're far from it. When I use mricron to look at the results from the spm8-format images, combined across participants to create a t-image, I just get a single 'blob' spanning roughly half the brain. In contrast, when I used spm2-format previously on the same data, the t-image was much more meaningful; a posterior alpha power decrease in a set of regions corresponding to the 'task-positive network' (a network found in the results of an fMRI version of my experiment, and widely reported in the fMRI literature). <br>
<br>This failure to replicate the spm2 results when using spm8 images from the same data leads me to suspect that something is wrong with the coordinates for spm8 format. However, after experimenting extensively with different cfg options I still haven't identified the problem. If I my structural MRIs have been saved to .mri files using CTF's MRIConverter program, which cfg options, particularly for coordinates, template images, and filetypes, should I specify before calling the ft_volumesegment, ft_prepare_singleshell, ft_sourceinterpolate, ft_volumenormalise, and ft_volumewrite functions? Or should I be calling a different set of functions now?<br>
<br>Thanks again for your help,<br><br>Jen<br><br><div class="gmail_quote">On Thu, Feb 24, 2011 at 10:07 AM, Jen Whitman <span dir="ltr"><<a href="mailto:jenwhitman@gmail.com" target="_blank">jenwhitman@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Great, thanks!<br><br>I'll start the analysis with your new script today and will let you know how it works out.<br>
<font color="#888888"><br>Jen<br><br></font><div class="gmail_quote"><div><div></div><div>On Thu, Feb 24, 2011 at 4:44 AM, jan-mathijs schoffelen <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div><div style="word-wrap: break-word;">Dear Jen,<div> <br></div>
<div>I managed to reproduce your problem. The code was rather buggy and indeed ft_volumewrite did not behave as it should have. I now fixed it in the code and it should run fine now. Please find the updated file attached. It will be available on our ftp-server as of tonight. Please note that I updated the documentation, and changed the names of some of the options a bit. If you want to save your data in analyze-format, you should specify cfg.filetype = 'analyze_spm'. If you specify cfg.filetype = 'nifti', it should write out a volume to nifti-format, using SPM8.</div>
<div><br></div><div>Best wishes,</div><div><br></div><font color="#888888"><div>Jan-Mathijs</div><div><br></div><div><br></div><div></div></font></div><br></div></div><div style="word-wrap: break-word;"><div></div><div>
<br>
</div><div> <br><div><div><div>On Feb 23, 2011, at 7:44 PM, Jen Whitman wrote:</div><br></div><div><div></div><div><blockquote type="cite"><br>Dear Jan,<br><br>Thanks for the quick reply. Yes, I have tried it out quite a few times now, experimenting with different settings in the cfgs. Below I'll paste the code I've been using to write images - first the code that successfully created spm2 images that produced good results, then the code used for creating nifti format images from the same data. The comments in this second part are at this point a bit of a maze of cfg options I've been changing back & forth. Any insights/suggestions regarding how to set up my cfgs to make this work would be greatly appreciated.<br>
<br>Jen<br><br><br>%%%%%%%% this code generated spm2-compatible images which did work (producing results that made sense).<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
<br> sourcetemp.avg.pow = (sourcetemp.avg.pow - sourcePre.avg.pow) ./ sourcePre.avg.pow;<br><br> cfg = [];<br> cfg.downsample = 2;<br> sourcetempInt = sourceinterpolate(cfg, sourcetemp , mri);<br><br> % projecting the plot onto a surface...<br>
cfg = [];<br> cfg.coordinates = 'ctf';<br> cfg.template = '/home/common/matlab/spm2/templates/T1.mnc'; %this template is in MNI coordinates<br> sourcetempIntN = volumenormalise(cfg, sourcetempInt);<br>
<br> filename=[subj 'run' int2str(r) 'cond' int2str(cond) '_' int2str(f) 'HzWin' int2str(win) 'width750ms'];<br> cfg=[];<br> cfg.parameter = 'avg.pow'; % string, describing the functional data to be processed, e.g. 'pow', 'coh' or 'nai'<br>
cfg.filename = [filename '.img']; %'testimageoutput_alphafreq'; % filename without the extension<br> cfg.filetype = 'spm'; %'analyze', 'spm', 'vmp' or 'vmr'<br>
cfg.coordinates = 'spm'; %'spm, 'ctf' or empty for interactive (default = [])<br> cfg.datatype = 'double'; %'float'; %'double'; %'bit1', 'uint8', 'int16', 'int32', 'float' or 'double'<br>
<br> volumewrite(cfg, sourcetempIntN)<br><br> <br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>%%%%% this code below hasn't worked yet...<br>
<br>% I added cfg.spmversion = 'spm8';<br>% in the cfgs for the calls to ft_prepare_leadfield and ft_sourceanalysis,<br>% and in the call to prepare_singleshell after calling volumesegment<br><br>% I've also ensured that spm8 is the only spm version in my path, even in<br>
% the fieldtrip/external folder, and ensured that spm8 is installed properly<br>% (files compiled correctly, etc..)<br><br> sourcetemp.avg.pow = (sourcetemp.avg.pow - sourcePre.avg.pow) ./ sourcePre.avg.pow;<br><br>
filename=[subj 'run' int2str(r) 'cond' int2str(cond) '_' int2str(f) 'Hzspm8_FIXv9_Win' int2str(win) 'width750ms.img'];<br>
<br> cfg = [];<br>% cfg.coordinates = 'spm'; % changed for version 5<br>% cfg.spmversion = 'spm8'; % changed for version 5<br> cfg.downsample = 4;<br> sourcetempInt = ft_sourceinterpolate(cfg, sourcetemp , mri);<br>
<br><br> % projecting the plot onto a surface...<br> cfg = [];<br> %cfg.coordinates = 'spm'; % changed for version 5<br> %cfg.coordinates = 'ctf'; % changed for version 5<br> cfg.coordinates = 'spm'; % changed back to spm for version 9<br>
cfg.downsample = 4;<br> %cfg.spmversion = 'spm8'; % changed for version 6 (because this gets specified in volumewrite)<br> cfg.template = 'Hmatrix/mask.nii.nii'; % basically equivalent to using spm8/templates/EPI.nii, except that mask.nii (produced from fmri data) has the desired voxel size<br>
% <a href="http://cfg.name" target="_blank">cfg.name</a> = [filename]; % changed for version 6<br> %cfg.write= 'yes'; % changed for version 6 (when this was set to 'yes' there was no subsequent call to volumewrite)<br>
cfg.write= 'no'; % changed for version 6<br> sourcetempIntN = ft_volumenormalise(cfg, sourcetempInt);<br> <br> % this whole cfg and function call added for version 6 <br> cfg=[];<br> % cfg.parameter = string, describing the functional data to be processed, e.g. 'pow', 'coh' or 'nai'<br>
% cfg.filename = filename without the extension<br>% cfg.filetype = 'analyze', 'spm', 'vmp' or 'vmr'<br>% cfg.vmpversion = 1 or 2 (default) version of the vmp-format to use<br>
% cfg.coordinates = 'spm, 'ctf' or empty for interactive (default = [])<br> cfg.parameter='pow';<br> cfg.filename=filename; <br> cfg.filetype = 'spm';<br> cfg.spmversion = 'SPM8'; % capitalized after first error message from vers 6<br>
% cfg.dataformat='nifti'; % added after first error message from vers 6<br> % commented out after 2nd error message from vers 6<br> %cfg.vmpversion=2; % this is a filetype, like spm, so don't need to specify unless cfg.filetyp='vmp' <br>
cfg.coordinates='spm';<br> ft_volumewrite(cfg,sourcetempIntN);<br><br> <br><br><br><br><div class="gmail_quote">On Wed, Feb 23, 2011 at 7:50 AM, jan-mathijs schoffelen <span dir="ltr"><<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank">jan.schoffelen@donders.ru.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Dear Jen,<br> <br> I notice that indeed in the documentation section of ft_write_volume there is a FIXME behind nifti. Yet, nifti format seems to be supported by ft_write_volume (at least in a recent version of fieldtrip). Did you try it at all (and ran into problems) or were you held back by the FIXME statement? Could you just try it out using a recent fieldtrip function?<br>
<br> Thanks and best wishes<br> <br> Jan-Mathijs<div><div></div><div><br> <br> <br> On Feb 23, 2011, at 2:21 AM, Jen Whitman wrote:<br> <br> </div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div> Hello,<br> <br> While writing beamformed images to spm2 format in a previous version of fieldtrip (now lost due to a computer crash), I was able to get nice-looking results; networks of brain regions consistent with existing literature. When I try to write images from the same dataset and the same analysis to spm8 format, my results (t-images computed across subjects) end up being single clusters spanning large sections of the brain (e.g. a 'blob' spanning all of one hemisphere but not the other). Unfortunately, some aspects of my planned data analyses cannot be performed on spm2 images, so I have to find a way of writing to successfully to nifti format.<br>
<br> I just noticed that in the comments in the ft_write_volume function, which I am calling via ft_volumewrite, it says 'FIXME' next to nifti under the list of supported dataformats. Is there by any chance a patch out there for writing nifti images?<br>
<br> Thanks!<br> <br></div></div> _______________________________________________<br> fieldtrip mailing list<br> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote> <br> Dr. J.M. (Jan-Mathijs) Schoffelen<br> Donders Institute for Brain, Cognition and Behaviour,<br> Centre for Cognitive Neuroimaging,<br> Radboud University Nijmegen, The Netherlands<br> <a href="mailto:J.Schoffelen@donders.ru.nl" target="_blank">J.Schoffelen@donders.ru.nl</a><br>
Telephone: 0031-24-3614793<br> <br> _______________________________________________<br> fieldtrip mailing list<br> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br> <a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
</blockquote></div><br> _______________________________________________<br>fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
</div></div></div><div><div></div><div><br><div> <div style="word-wrap: break-word;"><span style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"><div style="word-wrap: break-word;">
<div>Dr. J.M. (Jan-Mathijs) Schoffelen </div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>Radboud University Nijmegen, The Netherlands</div><div><a href="mailto:J.Schoffelen@donders.ru.nl" target="_blank">J.Schoffelen@donders.ru.nl</a></div>
<div>Telephone: 0031-24-3614793</div></div></span></div> </div><br></div></div></div></div><div><div></div><div><br>_______________________________________________<br> fieldtrip mailing list<br> <a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></div></div></blockquote></div><br> </blockquote></div><br> _______________________________________________<br>
fieldtrip mailing list<br><a href="mailto:fieldtrip@donders.ru.nl" target="_blank">fieldtrip@donders.ru.nl</a><br><a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></blockquote>
</div><br><div> <div style="word-wrap: break-word;"><div style="word-wrap: break-word;"><div>Dr. J.M. (Jan-Mathijs) Schoffelen </div><div>Donders Institute for Brain, Cognition and Behaviour, <br>Centre for Cognitive Neuroimaging,<br>
Radboud University Nijmegen, The Netherlands</div><div><a href="mailto:J.Schoffelen@donders.ru.nl" target="_blank">J.Schoffelen@donders.ru.nl</a></div><div>Telephone: 0031-24-3614793</div></div></div> </div><br></div></div>
<br>_______________________________________________<br>
fieldtrip mailing list<br>
<a href="mailto:fieldtrip@donders.ru.nl">fieldtrip@donders.ru.nl</a><br>
<a href="http://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank">http://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br></blockquote></div><br>