[FieldTrip] difficulty with nifti format and ft_write_volume

jan-mathijs schoffelen jan.schoffelen at donders.ru.nl
Thu Feb 24 07:58:24 CET 2011


Hi Jen,

Thanks for sending the code.
What is the actual error message you are getting?

Best wishes,

Jan-Mathijs


On Feb 23, 2011, at 7:44 PM, Jen Whitman wrote:

>
> Dear Jan,
>
> 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.
>
> Jen
>
>
> %%%%%%%% this code generated spm2-compatible images which did work  
> (producing results that made sense).
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
>     sourcetemp.avg.pow = (sourcetemp.avg.pow - sourcePre.avg.pow) ./  
> sourcePre.avg.pow;
>
>     cfg = [];
>     cfg.downsample = 2;
>     sourcetempInt = sourceinterpolate(cfg, sourcetemp , mri);
>
>     % projecting the plot onto a surface...
>     cfg = [];
>     cfg.coordinates  = 'ctf';
>     cfg.template     = '/home/common/matlab/spm2/templates/T1.mnc';  
> %this template is in MNI coordinates
>     sourcetempIntN = volumenormalise(cfg, sourcetempInt);
>
>     filename=[subj 'run' int2str(r) 'cond' int2str(cond) '_'  
> int2str(f) 'HzWin' int2str(win) 'width750ms'];
>     cfg=[];
>     cfg.parameter     = 'avg.pow'; % string, describing the  
> functional data to be processed, e.g. 'pow', 'coh' or 'nai'
>     cfg.filename      = [filename '.img'];  
> %'testimageoutput_alphafreq'; % filename without the extension
>     cfg.filetype      = 'spm'; %'analyze', 'spm', 'vmp' or 'vmr'
>     cfg.coordinates   = 'spm'; %'spm, 'ctf' or empty for interactive  
> (default = [])
>     cfg.datatype = 'double'; %'float'; %'double'; %'bit1', 'uint8',  
> 'int16', 'int32', 'float' or 'double'
>
>     volumewrite(cfg, sourcetempIntN)
>
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> %%%%% this code below hasn't worked yet...
>
> % I added    cfg.spmversion = 'spm8';
> % in the cfgs for the calls to ft_prepare_leadfield and  
> ft_sourceanalysis,
> % and in the call to prepare_singleshell after calling volumesegment
>
> % I've also ensured that spm8 is the only spm version in my path,  
> even in
> % the fieldtrip/external folder, and ensured that spm8 is installed  
> properly
> % (files compiled correctly, etc..)
>
>     sourcetemp.avg.pow = (sourcetemp.avg.pow - sourcePre.avg.pow) ./  
> sourcePre.avg.pow;
>
>     filename=[subj 'run' int2str(r) 'cond' int2str(cond) '_'  
> int2str(f) 'Hzspm8_FIXv9_Win' int2str(win) 'width750ms.img'];
>
>     cfg = [];
> %     cfg.coordinates  = 'spm'; % changed for version 5
> %     cfg.spmversion = 'spm8'; % changed for version 5
>     cfg.downsample = 4;
>     sourcetempInt = ft_sourceinterpolate(cfg, sourcetemp , mri);
>
>
>     % projecting the plot onto a surface...
>     cfg = [];
>     %cfg.coordinates  = 'spm'; % changed for version 5
>     %cfg.coordinates  = 'ctf'; % changed for version 5
>     cfg.coordinates = 'spm'; % changed back to spm for version 9
>     cfg.downsample = 4;
>     %cfg.spmversion = 'spm8'; % changed for version 6 (because this  
> gets specified in volumewrite)
>     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
>     % cfg.name = [filename]; % changed for version 6
>     %cfg.write= 'yes'; % changed for version 6 (when this was set to  
> 'yes' there was no subsequent call to volumewrite)
>     cfg.write= 'no';   % changed for version 6
>     sourcetempIntN = ft_volumenormalise(cfg, sourcetempInt);
>
>     % this whole cfg and function call added for version 6
>     cfg=[];
>     %   cfg.parameter     = string, describing the functional data  
> to be processed, e.g. 'pow', 'coh' or 'nai'
> %   cfg.filename      = filename without the extension
> %   cfg.filetype      = 'analyze', 'spm', 'vmp' or 'vmr'
> %   cfg.vmpversion    = 1 or 2 (default) version of the vmp-format  
> to use
> %   cfg.coordinates   = 'spm, 'ctf' or empty for interactive  
> (default = [])
>     cfg.parameter='pow';
>     cfg.filename=filename;
>     cfg.filetype = 'spm';
>     cfg.spmversion = 'SPM8'; % capitalized after first error message  
> from vers 6
> %   cfg.dataformat='nifti';  % added after first error message from  
> vers 6
>                                  % commented out after 2nd error  
> message from vers 6
>     %cfg.vmpversion=2; % this is a filetype, like spm, so don't need  
> to specify unless cfg.filetyp='vmp'
>     cfg.coordinates='spm';
>     ft_volumewrite(cfg,sourcetempIntN);
>
>
>
>
>
> On Wed, Feb 23, 2011 at 7:50 AM, jan-mathijs schoffelen <jan.schoffelen at donders.ru.nl 
> > wrote:
> Dear Jen,
>
> 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?
>
> Thanks and best wishes
>
> Jan-Mathijs
>
>
>
> On Feb 23, 2011, at 2:21 AM, Jen Whitman wrote:
>
> Hello,
>
> 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.
>
> 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?
>
> Thanks!
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
> Dr. J.M. (Jan-Mathijs) Schoffelen
> Donders Institute for Brain, Cognition and Behaviour,
> Centre for Cognitive Neuroimaging,
> Radboud University Nijmegen, The Netherlands
> J.Schoffelen at donders.ru.nl
> Telephone: 0031-24-3614793
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

Dr. J.M. (Jan-Mathijs) Schoffelen
Donders Institute for Brain, Cognition and Behaviour,
Centre for Cognitive Neuroimaging,
Radboud University Nijmegen, The Netherlands
J.Schoffelen at donders.ru.nl
Telephone: 0031-24-3614793

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20110224/52ea01f5/attachment-0001.html>


More information about the fieldtrip mailing list