[Mrtrix-discussion] Question about convert from nii to mif

Donald Tournier d.tournier at brain.org.au
Mon Jul 30 18:50:07 PDT 2012


Hi again,

OK, I'm also stumped. Given that error message, your system doesn't like
some of the arguments to the mmap() call. I can't think what it might not
like, I've been through the documentation for mmap() and it should work
fine (as it has done quite happily until now). Can I just confirm what OS
this is running on? I'm assuming a 64-bit Linux system within a virtual
machine (given the machine name on the command-line prompt), is this
correct? And what flavour of Linux are you running, and in particular what
kernel version? The output of "uname -a" and "lsb_release -a" should tell
you all that information.

Otherwise, to try to debug this further, can you add the lines highlighted
below to the file lib/file/mmap.cpp, at the specified position, re-build,
re-install and run the modified mrconvert command again?

 84         if (!addr) throw 0;
 85         CloseHandle (handle);
 86 #else
*            VAR (msize);*
*            VAR (fd);*
*            VAR (read_only);*
 87         addr = (void *) mmap((char*)0, msize, (read_only ? PROT_READ :
PROT_READ | PROT_WRITE), MAP_SHARED, fd, 0);
 88         if (addr == MAP_FAILED) throw 0;
 89 #endif

Of these, the only parameter that could realistically go wrong is msize
being set to zero, but I can't figure out why that would happen. Maybe it
would be simpler if you could send me the dataset...?

Cheers,

Donald.


On 31 July 2012 11:02, dti mic <micdtiserver at gmail.com> wrote:

> Dear Donald,
>
> Thank you so much for the prompt response. I tried all your suggested
> commands and below please find the output of them:
>
> 1. $ mrinfo P481210209_xyz_eddy_Ave.nii (it is a mouse data, so the
> dimension and voxel size is way smaller than human, but I assume that
> should not be the reason of my failure in mrconvert?)
> ************************************************
> Image:               "P481210209_xyz_eddy_Ave.nii"
> ************************************************
>   Format:            NIfTI-1.1
>   Dimensions:        105 x 180 x 80 x 31
>   Voxel size:        0.1 x 0.1 x 0.1 x 1
>   Dimension labels:  0. left->right (mm)
>                      1. posterior->anterior (mm)
>                      2. inferior->superior (mm)
>                      3. undefined (?)
>   Data type:         64 bit float (little endian)
>   Data layout:       [ +0 +1 +2 +3 ]
>   Data scaling:      offset = 0, multiplier = 1
>   Comments:          FSL4.1
>   Transform:                    1           0           0           0
>                                 0           1           0           0
>                                 0           0           1           0
>                                 0           0           0           1
>
> 2. $ mrconvert P481210209_xyz_eddy_Ave.nii dwi.mif -debug  (Please kindly
> note that I have successfully worked through all the steps with the same
> input image in a FSL pipeline, including both tensor estimation and
> tractography).
> mrconvert [DEBUG]: reading key/value file "/etc/mrtrix.conf"...
> mrconvert [INFO]: opening image "P481210209_xyz_eddy_Ave.nii"...
> mrconvert [DEBUG]: preparing file "./P481210209_xyz_eddy_Ave.nii"
> mrconvert [DEBUG]: file "./P481210209_xyz_eddy_Ave.nii" mapped at
> 0x7fcacb920000, size 374976352 (read-only)
> mrconvert [DEBUG]: sanitising transformation matrix...
> mrconvert [DEBUG]: unmapping file "./P481210209_xyz_eddy_Ave.nii"
> mrconvert [DEBUG]: setting up image "P481210209_xyz_eddy_Ave.nii"...
> mrconvert [DEBUG]: sanitising transformation matrix...
> mrconvert [DEBUG]: setting up data increments for
> "P481210209_xyz_eddy_Ave.nii"...
> mrconvert [DEBUG]: data increments initialised with start = 0, stride = [
> 1 105 18900 1512000 ]
> mrconvert [DEBUG]: mapping image "P481210209_xyz_eddy_Ave.nii"...
> mrconvert [DEBUG]: file "./P481210209_xyz_eddy_Ave.nii" mapped at
> 0x7fcacb920000, size 374976352 (read-only)
> mrconvert [DEBUG]: data mapper for image "P481210209_xyz_eddy_Ave.nii"
> mapped with segment size = 46872000
> mrconvert [INFO]: creating image "dwi.mif"...
> mrconvert [DEBUG]: preparing file "./dwi.mif"
> mrconvert [DEBUG]: setting up image "./dwi.mif"...
> mrconvert [DEBUG]: sanitising transformation matrix...
> mrconvert [DEBUG]: setting up data increments for "./dwi.mif"...
> mrconvert [DEBUG]: data increments initialised with start = 0, stride = [
> 1 105 18900 1512000 ]
> mrconvert [DEBUG]: mapping image "./dwi.mif"...
> mrconvert: memory-mapping failed for file "./dwi.mif": Invalid argument
> mrconvert [INFO]: closing image "P481210209_xyz_eddy_Ave.nii"...
> mrconvert [DEBUG]: unmapping file "./P481210209_xyz_eddy_Ave.nii"
> mrconvert [INFO]: closing image "./dwi.mif"...
>
> 3. $ ls -l dwi.mif
> -rwxrwx---. 1 root vboxsf 374976262 Jul 31 10:54 dwi.mif
>
> Honestly, I can not tell what is wrong from the above information and your
> help will be highly appreciated!
>
> Please kindly note that the input image (P481210209_xyz_eddy_Ave.nii) I
> provide to mrconvert is a output from previous processing steps (dcm2nii,
> Eddy_current from FSL and averaged multiple B0 image by fslmaths etc.). I
> really want to start mrtrix from this point on. That is why I did not feed
> mrtrix with the original raw dicom.
>
> Many thanks again!
>
> micdtiserver
>
> 2012/7/31 Donald Tournier <d.tournier at brain.org.au>
>
>> Hi,
>>
>> This is indeed weird. The only reason I can think of why this might
>> happen is that the output dwi.mif file is somehow created with the wrong
>> filesize. One possible issue might be that one of the dimensions is set to
>> zero, which would cause the data size to be zero. But then I'm pretty sure
>> MRtrix checks all of that. Maybe in the first instance you could post the
>> output of:
>>
>> $ mrinfo P481210209_xyz_eddy_Ave.nii
>>
>> You could also provide the output of the failing command with the -debug
>> option:
>>
>> $ mrconvert P481210209_xyz_eddy_Ave.nii dwi.mif -debug
>>
>> and provide a full listing for the output file (which I assume does get
>> created?):
>>
>> $ ls -l dwi.mif
>>
>> That should already provide some clues as to what is going on. If that
>> doesn't help, you could always send me the file if you're comfortable with
>> that.
>>
>> Cheers,
>>
>> Donald.
>>
>>
>>
>> On 30 July 2012 17:08, dti mic <micdtiserver at gmail.com> wrote:
>>
>>> Dear MRtrix,
>>>
>>> I am trying to convert a 4D dwi data set in NIFTI format (converted from
>>> DICOM using dcm2nii) into mif image. The error message I got is:
>>>
>>> "mrconvert: memory-mapping failed for file "./dwi.mif": Invalid
>>> argument". The input image (the name of which is
>>> "P481210209_xyz_eddy_Ave.nii", a little bit long and wired I know) in nii
>>> format can be well accessed by FSL and MRIcron or MRIcron. Any idea of what
>>> I can do to fix this issue? Should I try some more options in the mrconvert
>>> command?
>>>
>>> Many thanks for your help in advance!
>>>
>>>
>>>
>>> _______________________________________________
>>> Mrtrix-discussion mailing list
>>> Mrtrix-discussion at www.nitrc.org
>>> http://www.nitrc.org/mailman/listinfo/mrtrix-discussion
>>>
>>>
>>
>>
>> --
>> Jacques-Donald Tournier (PhD)
>> Brain Research Institute, Melbourne, Australia
>> Tel: +61 (0)3 9035 7033
>>
>
>


-- 
Jacques-Donald Tournier (PhD)
Brain Research Institute, Melbourne, Australia
Tel: +61 (0)3 9035 7033
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.nitrc.org/pipermail/mrtrix-discussion/attachments/20120731/4f2da8aa/attachment.html


More information about the Mrtrix-discussion mailing list