Dear Luca,
spm_get_space(P,M) will save the new header to the original file, with
unmodified data. If you want to change other fields from the header,
then use a combination of spm_vol/spm_create_vol (or nifti/create).
The "reset orientation" option does the following (SPM8 help text):
> % The ``Reset...'' button [...] is for setting the orientation of
> % images back to transverse. It retains the current voxel sizes,
> % but sets the origin of the images to be the centre of the volumes
> % and all rotations back to zero.
so it's not exactly going back to the original settings and seems to be
a left-over from the Analyze days.
Best regards,
Guillaume.
On 21/06/16 11:21, PRESOTTO LUCA wrote:
> Thank you for your answer,
>
> I've looked into the spm_get_space function but I'm not 100% sure how to apply it to my problem. If I use "create" then it replaces the header of my original file with the new header? BTW, the times I've needed to do something like this were to either reorient an image (i.e.: apply the mat of frame one to all other frames) but also to scale the intensity of an image.
>
> (just of curiosity, whe was "reset orientation" removed? seems quite difficult now to go back to the original settings if you make an error somewhere)
>
> Thank you again,
>
> Luca
> ________________________________________
> Da: Guillaume Flandin <[log in to unmask]>
> Inviato: martedì 21 giugno 2016 12.00.55
> A: PRESOTTO LUCA
> Cc: [log in to unmask]
> Oggetto: Re: [SPM] Modifying headers without reading the whole image volume
>
> Dear Luca,
>
> To change the voxel-to-world mapping of an image, have a look at the
> spm_get_space function.
>
> The 'reset orientation" option is indeed not available any more from the
> SPM12 interface but you can still call it manually with:
>
>>> spm_image('resetorient');
>
> Best regards,
> Guillaume.
>
>
> On 21/06/16 10:45, PRESOTTO LUCA wrote:
>> Dear SPMers,
>>
>> I was looking into reorienting some images in some scripts I'm writing. However, I can't find a way anywhere to just modifiy the header of the image. The only workaround I can find is to do:
>>
>> V = spm_vol (filename);
>> imVol = spm_read_vols(v);
>>
>> % compute modifications to V.mat
>>
>> spm_write_vols(V,imVol);
>>
>> I'm pretty sure that there must be a way to do this without reading the whole volume and then rewriting it identically. I think that this was the original reason that analyze was implemented this way. However, I can't find how.
>>
>> Am I missing some routines somewhere?
>>
>> thank you,
>>
>> Luca
>>
>> (BTW, is it me or in spm12 it's impossible to "reset" the orientation of an image????)
>>
>>
>> Rispetta l’ambiente: non stampare questa mail se non è necessario.
>> Respect the environment: if it's not necessary, don't print this mail.
>>
>> IL TUO 5XMILLE AL SAN RAFFAELE DI MILANO
>>
>> Devolvi il tuo 5 per mille all’Ospedale San Raffaele: perché al centro della Ricerca ci sei TU. CODICE FISCALE: 07636600962, nel riquadro RICERCA SANITARIA. Non c’è cura, senza ricerca. Non c’è ricerca, senza il tuo 5xmille. Scopri come su http://www.5xmille.org
>>
>> [http://www.5xmille.org/img/731x129.jpg]
>>
>
> --
> Guillaume Flandin, PhD
> Wellcome Trust Centre for Neuroimaging
> University College London
> 12 Queen Square
> London WC1N 3BG
>
>
> Rispetta l’ambiente: non stampare questa mail se non è necessario.
> Respect the environment: if it's not necessary, don't print this mail.
>
> IL TUO 5XMILLE AL SAN RAFFAELE DI MILANO
>
> Devolvi il tuo 5 per mille all’Ospedale San Raffaele: perché al centro della Ricerca ci sei TU. CODICE FISCALE: 07636600962, nel riquadro RICERCA SANITARIA. Non c’è cura, senza ricerca. Non c’è ricerca, senza il tuo 5xmille. Scopri come su http://www.5xmille.org
>
> [http://www.5xmille.org/img/731x129.jpg]
>
--
Guillaume Flandin, PhD
Wellcome Trust Centre for Neuroimaging
University College London
12 Queen Square
London WC1N 3BG
|