writing a .mha file

1,081 views
Skip to first unread message

Mohammad Havaei

unread,
Jul 23, 2013, 2:48:56 PM7/23/13
to gerardu...@googlegroups.com
 I am currently working with MR Images which are in '.mha' format. I am looking for a package in Matlab which enables me to read and write these type of files. I understand that you have a piece of code 'writemhafile.m' and 'writemetafile.m' which can write mha files. I tired to use them I got error . this is how I approached it. 

I read the mha file using  'mha_read_volume.m' Which I found on the internet 

V = mha_read_volume(filepath);

I then do some processing and I use your function to save it

WriteMetaFile('foo.mha', V, [160,216,176],'uint8')

but then I get error in line 62 of writemetafile.m 

later I came to know that there is another m file writemetaimagefile.m  which can produce an mha file directly . so im using that now. Is this the way to go or am I missing a step here?

Thank you

Ramón Casero Cañas

unread,
Jul 23, 2013, 2:58:11 PM7/23/13
to Gerardus Users Mailing List
Hi Mohammad,

The gerardus Matlab functions to read and write files are here


You should try with

scimat = scinrrd_load('path/to/file/file.mha');

to read the file. This will create a struct called scimat, with the image

scimat.data

and some metainformation about the voxel size, etc.

scimat.axis

It cannot read .mha files that have been compressed, I think.

Process your image scimat.data, and then to save the result you can do

scinrrd_save('result.mha', scimat);

If you need to create a scimat struct from scratch, you can use function scinrrd_im2nrrd


Cheers,

Ramon.



--
--
To post: gerardu...@googlegroups.com
To unsubscribe: gerardus-user...@googlegroups.com
More options: http://groups.google.com/group/gerardus-users?hl=en?hl=en
 
---
You received this message because you are subscribed to the Google Groups "gerardus-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gerardus-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Dr. Ramón Casero Cañas

Oxford e-Research Centre (OeRC)
University of Oxford
7 Keble Rd
Oxford OX1 3QG

tlf         +44 (0) 1865 610739
twitter   @Ramon_Casero
web      http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas
photos  http://www.flickr.com/photos/rcasero/
Message has been deleted

Ramón Casero Cañas

unread,
Apr 9, 2016, 5:48:48 AM4/9/16
to Gerardus Users Mailing List
Hi Quod...,

That's an old link. Since, the project has moved to github.


Because the old link redirects to the root of the new project, I'm not sure whether you are using an old or new version, and I'm not sure which function you are using either. (I'm assuming, scimat_save?).

Also, without a specific example, it's not possible to check whether our function actually has a problem or the problem is with the other package. (So far, it has worked for us!).

Cheers,

Ramon.


On 9 April 2016 at 10:34, <quodlibetenses...@gmail.com> wrote:
Hi, 

the link of writing mha code above is not robust enough. The output file is invalid sometime, for example, when you use plastimatch/drr.

A better is in here: install plastimatch first, then find ...../extra/matlab/writemha.m
For more options, visit https://groups.google.com/d/optout.



--
Dr. Ramón Casero Cañas

Institute of Biomedical Engineering
Department of Engineering Science, University of Oxford
Old Road Campus Research Building, Headington 
Oxford 
OX3 7DQ
UK

tlf         +44 (0) 1865 617716
twitter   @Ramon_Casero
web      http://www.cs.ox.ac.uk/people/Ramon.CaseroCanas/

Ramón Casero Cañas

unread,
Apr 9, 2016, 5:51:02 AM4/9/16
to Gerardus Users Mailing List, quodlibetenses...@gmail.com
Hi Yi,

That's an old link. Since, the project has moved to github.


Because the old link redirects to the root of the new project, I'm not sure whether you are using an old or new version, and I'm not sure which function you are using either. (I'm assuming, scimat_save?).

Also, without a specific example, it's not possible to check whether our function actually has a problem or the problem is with the other package. (So far, it has worked for us!).

Cheers,

Ramon.

On 9 April 2016 at 10:34, <quodlibetenses...@gmail.com> wrote:
Hi, 

the link of writing mha code above is not robust enough. The output file is invalid sometime, for example, when you use plastimatch/drr.

A better is in here: install plastimatch first, then find ...../extra/matlab/writemha.m

On Wednesday, 24 July 2013 02:58:11 UTC+8, Ramón Casero Cañas wrote:
For more options, visit https://groups.google.com/d/optout.



--
Dr. Ramón Casero Cañas
Reply all
Reply to author
Forward
0 new messages