It should probably be "fnam = fullfile(po, [nm '_seg_sn.mat']);
* po instead of p *
________________________________________
From: SPM (Statistical Parametric Mapping) [[log in to unmask]] On Behalf Of Vy Dinh [[log in to unmask]]
Sent: Wednesday, July 07, 2010 6:35 PM
To: [log in to unmask]
Subject: Re: [SPM] Generating *seg_sn.mat file using spm_segment.m
Hi Marko,
Thank you so much for the code. Considering that I'm a novice with Matlab and spm, I was wondering if you can help figure out why the code is not working in my script. Here's how I started the script:
ana = 'path to structural image'
nm = 'H'
results = spm_preproc(ana); %using default settings, so I left out "opts_seg" here
......(the rest of the script remained the same)
However, I get an error when I ran this script.
??? Undefined function or variable 'p'.
Error in ==> segment_test at 15
fnam = fullfile(p,[nm '_seg_sn.mat']);
Is "p" a structure? Also, after what function is this structure/variable created?
Thanks in advance,
Vy
On Fri, Jul 2, 2010 at 2:01 AM, Marko Wilke <[log in to unmask]<mailto:[log in to unmask]>> wrote:
Hi Vy,
Is there a way to generate the *seg_sn.mat file using spm_segment in
a script?
Yes there is :) You can call the respective functions from the command line, and thus, also in a script. Note that you do not want to use spm_segment as that is the old-old segmentation (if new segment is new, unified segmentation is already old and spm_segment is older still :)
Say that ana is your anatomical (with nm being its name) and opts_seg are the options you specified, something like
% segment dataset
results = spm_preproc(ana, opts_seg);
% process generated spatial normalization parameters
[po,pin] = spm_prep2sn(results);
% save parameters (forward)
VG = po.VG;
VF = po.VF;
Tr = po.Tr;
Affine = po.Affine;
flags = po.flags;
fnam = fullfile(p,[nm '_seg_sn.mat']);
save(fnam,'-V6','VG','VF','Tr','Affine','flags');
% save parameters (inverse)
VG = pin.VG;
VF = pin.VF;
Tr = pin.Tr;
Affine = pin.Affine;
flags = pin.flags;
fnam = fullfile(p,[nm '_seg_inv_sn.mat']);
save(fnam,'-V6','VG','VF','Tr','Affine','flags');
... should work. You will still have to write out your results using spm_preproc_write, but for the parameters themselves, that should work.
Hope this helps,
Marko
--
=====================================================================
Marko Wilke (Dr.med./M.D.)
[log in to unmask]<mailto:[log in to unmask]>
Universitäts-Kinderklinik University Children's Hospital
Abt. III (Neuropädiatrie) Dept. III (Pediatric neurology)
Hoppe-Seyler-Str. 1, D - 72076 Tübingen
Tel.: (+49) 07071 29-83416 Fax: (+49) 07071 29-5473
=====================================================================
--
Vy T.U. Dinh
Research Assistant, Neurological Sciences
Rush University Medical Center
Phone: (312) 563-3853
Fax: (312) 563-4660
Email: [log in to unmask]<mailto:[log in to unmask]>
|