Hi Yaroslav and Pádraig,
Please follow the link pasted below to get an alpha version of pymgh.
It requires the latest Python and Numpy.
https://www.nmr.mgh.harvard.edu/facility/filedrop/showgroup/10224/1/2a5da2a125134fbdfc9e6850be1fcc09
(expires in 30 days )
Make sure PYTHONPATH has the directory which contains 'pymgh'. Found
by typing,
>>>import sys
>>>sys.path
As far as the usage goes, pymgh basically instantiates a "MGH" class
( which contains details about the header as well as the data ) when
you call the load() method. There is a class save() method as well as
a module save() method ( static function)
The following examples will throw more light.
from pymgh import mgh
m = mgh.MGH()
m.load('test.mgz') # this loads information from test.mgz onto m.
Both .mgh and .mgz work
m.header # see the header information
m.vol # the N-D numpy volume of the same datatype as mri_type
v = m.vol * 3 # some basic manipulation
m.save(filename = 'modtest.mgz', volume = v ) # save the new volume
with same headers onto a different file
There is also a module method mgh.save() which requires all keyword
arguments. More documentation on functions are found in their
docstrings and I am afraid it's the only documentation available now.
pymgh mostly follows the structure in the wiki page describing
MGHformat. And the resulting Numpy volume has the exact shape as the
MATLAB volume loaded by load_mgh.m
This package is fresh, so expect surprises. I request you to go to the
tests/ directory and run the test_mgh_io.py before everything. It has
a few basic sanity tests.
cd tests/
python test_mgh_io.py -v 2
Contact me ( krish @ nmr... ) if you want to report a bug /
suggestions etc.
Thanks
Krish
On Apr 24, 2008, at 1:23 PM, Yaroslav Halchenko wrote:
well, I can leave with 1 time conversion ;) Having direct interface
from python
is a neat thing to have though. by ldd on mris_convert and its size
(3MB) I
guess freesurfer statically compiles in IO functionality in. It
would be great
if there just was a dynamic library which does IO. Then it could be
quite easy
to create python wrapper which would use it more or less directly...
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer