Print

Print


Dear Paul Macey:

Your script is exactly what I was looking for, and allows me to apply 
bias correction onto other anatomical sequences like FLAIR, T2W, and 
etc.  However  I have one question.  Can you assume EPI field 
inhomogeneity, or distortion, is similar to anatomical sequence? 

With regards,

Hedok


Paul Macey wrote:
> Hi Marko
>
> Although I haven't used the old SPM2 bias correction in SPM5, I did 
> write a short script to apply the bias correction as determined in the 
> SPM5 unified segmentation to images other than the input image (m-file 
> attached). This is not what you asked for, but it may be handy for you 
> or others. I've used this to correct bias in EPI images - I run the 
> SPM5 segment on the mean image, then apply the correction to all the 
> images in the series.
>
> Best wishes,
> Paul
>
> Marko Wilke wrote:
>> Dear All,
>>
>> I know, the bias estimation as implemented in the segmentation is 
>> superior but I would still like to play around with the command line 
>> version that directly estimates the bias in the image as implemented 
>> in spm_bias_estimate and spm_bias_apply.
>>
>> It seems that the estimation did not change from spm2 to spm5 but the 
>> process works in spm2 and does not in spm5... specifically, if I call 
>> spm_bias_estimate, I get an error related to the plotting of results 
>> ("vectors must be the same length"), or Matlab crashes completely. 
>> Uncommenting the plot still crashes Matlab, so the error seems to be 
>> in the mex-file. Using the spm2-dll does not work as the spm_vol 
>> syntax changed, and re-compiling the spm5-version also does not 
>> succeed, likely due to the inaptness of the operator.
>>
>> My question is, has anyone used spm_bias_estimate in spm5 on a 
>> Windows machine? If so, I would appreciate receiving your dll-file to 
>> see if it is a local problem.
>>
>> Best regards and thanks in advance,
>> Marko
>>
> ------------------------------------------------------------------------
>
> function cspm_bias_writecorrected( sn_file, P )
>     if ~strcmp(spm('ver'),'SPM5')
>         msgbox('Function works with SPM5 only.')
>         return
>     end
>     if nargin < 1
>         sn_file = spm_select(1,'mat',...
>             'Select spatial normalization parameters (from segment/unified)');
>     end
>     if nargin < 2
>         P = spm_select(Inf,'image',...
>             'Select files to be bias-corrected using sn parameters');
>     end
>     if iscell(P)
>         P = char(P);
>     end
>
>     sn = load(sn_file);
>
>     opts.biascor = 1;
>     opts.GM = [0 0 0];
>     opts.WM = [0 0 0];
>     opts.CSF = [0 0 0];
>     opts.cleanup = 0;
>
>     % Rename priors as the path will vary according to SPM5 location
>     sn.VG(1) = spm_vol( fullfile(spm('dir'),'apriori','grey.nii') );
>     sn.VG(2) = spm_vol( fullfile(spm('dir'),'apriori','white.nii') );
>     sn.VG(3) = spm_vol( fullfile(spm('dir'),'apriori','csf.nii') );
>
>     for m = 1:size(P,1)
>         sn.VF = spm_vol(deblank(P(m,:)));
>         spm_preproc_write(sn,opts)
>     end
>