Print

Print


As I said, this isn’t trivial and would require some manual manipulation of the data using Matlab and SPM commands/functions– there is no way to do this with mouse clicks using a UI (at least not that I’m aware). Again, the best and safest thing to do is to try to re-export the scan from the scanner. If that’s not possible or doesn’t solve the problem. The steps I would take are:

1)      load the raw data into a 3D-matrix with 

V=spm_vol(spm_select()); IMG=spm_read_vols(V);

Your variable IMG will now be a 3D matrix with the dimensions of your scan (e.g. 240x240x180). Individual slices are the third dimension in this matrix.

2)      Identify which slice is wrong

imagesc(IMG(:,:,z));  
ß here you need to vary the value of z until you find the problematic slice

3)      save this slice into a new 2D matrix:

SLICE=IMG(:,:,z);  

4)      shift the data in this slice until it seems to fit with the two neighbouring slices:

SLICEshifted=circshift(SLICE,[xOffset yOffset]);

You need to determine the values of xOffset and yOffset yourself, either by visual comparison of the neighbouring slices, or by identifying a feature in the image that runs mostly laterally through all slices. This will likely involve a good deal of trial-and-error.

5)      Once the slice is shifted into the proper position, it needs to be re-inserted into the 3D matrix and then saved as nifti image:

IMG(:,:,z)=SLICEshifted;
spm_write_vol(V,IMG);

Optionally, before running spm_write_vol, you could change the file name it will be saved under, by changing the content of V.fname:

V.fname=’manipulated_image.nii’;

A few other comments: the above procedure assumes that the problematic slice is only shifted with respect to the other slices, not rotated. If it looks as if it is also rotated, or otherwise deformed, you need different procedures, and are likely out of luck. Also, depending on what you want to do with the file, I would always treat this file with some suspicion, even after it’s been “fixed”. Estimating normalization parameters is probably fine, but I’m not sure if would use this file for VBM type analyses.

Best wishes,

Andreas

 

From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]] On Behalf Of charujing123
Sent: 22 January 2014 13:12
To: [log in to unmask]
Subject: Re: [SPM] 3d image has a dislocation slice

 

Hi Andreas,

Thanks Andreas.

I am sorry about too little information in the previous e-mail.

Format of this data is *.nii, and in the sagittal orientation this slice still looks like a proper brain slice.However I do not know how to manually shift the whole slice.

Would you please tell me a manu to fix it?

Thanks.

All the best.

Rujing Zha

 

2014-01-22


charujing123


发件人:Andreas Finkelmeyer <[log in to unmask]>

发送时间:2014-01-22 18:06

主题:RE: [SPM] 3d image has a dislocation slice

收件人:"charujing123"<[log in to unmask]>

抄送:

 

Hi Rujing Zha,

It looks like a simple offset error in the data, which should be fixable. Without knowing exactly where the data came from (which format, which file conversions), it’s difficult to say at what stage of processing it occurred. If you have the option, I would first try to re-export the image from the scanner itself. If that doesn’t help, you could see if the slice itself is spatially shifted, i.e. if you look at only this slice it still looks like a proper brain slice, or if it looks like bytes were shifted and the slice itself looks like a collection of shifted rows or columns. In both cases you could then try to manually shift the whole slice or bytes. The last option would be to interpolate that slice from the two slices surrounding it. Apart from the first option (re-export), you would have to get into and manipulate the file-level representation of the image. Depending on your skill set, this might be somewhat daunting, but can also be a very valuable learning experience.

Good luck,
Andreas

===================================================

Andreas Finkelmeyer, Ph.D.

Academic Psychiatry, Institute of Neuroscience

Wolfson Research Centre, Campus for Ageing and Vitality

Newcastle University

Newcastle upon Tyne

NE4 5PL, UK

Tel.: +44 (0)191 208 1357

Web: www.ncl.ac.uk/ion

From: SPM (Statistical Parametric Mapping) [mailto:[log in to unmask]] On Behalf Of charujing123
Sent: 22 January 2014 07:04
To: [log in to unmask]
Subject: [SPM] 3d image has a dislocation slice

Hi all,

I have a 3d image which has a problem: one slice drops away from the others.How can I fix the problem. Image can be got from the attachment.

Thanks.

All the best.

Rujing Zha

University of Science and Technology of China

2014-01-22


charujing123