BIC-MNI / minc-tools

Basic minc-tools from former minc repository
Other
30 stars 25 forks source link

mnc2nii treats minc files touched by different minc tools differently #69

Closed gdevenyi closed 4 years ago

gdevenyi commented 7 years ago

Running into a very weird bug in minc-toolkit/1.9.15:

Example 1: have brain1.mnc and brain1_mask.mnc if I do

> mincmask brain1.mnc brain1_mask.mnc brain1_extracted.mnc
> mnc2nii brain1_extracted.mnc brain1_extracted.nii

I get NIFTI file that has the orientation re-arranged (i.e. no longer in the same space) If instead I do:

> mincmath -mult brain1.mnc brain1_mask.mnc brain1_extracted.mnc
> mnc2nii brain1_extracted.mnc brain1_extracted.nii

Everything is fine

Example 2: have brain1_mask.mnc

> mnc2nii brain1_mask.mnc brain1_mask.nii

Everything is fine.

> mincmorph -successive DDDDDDDD brain1_mask.mnc brain1_mask_D.mnc
> mnc2nii brain1_mask_D.mnc brain1_mask_D.nii

Same problems as above.

Example of the swapped orientation problem: image

andrewjanke commented 7 years ago

HI Gabriel,

My punt is a apparent vs file dimension order bug. I'm currently having the same issues with volextents as it seems that what I originally wrote to try to handle this doesn't work anymore:

https://github.com/BIC-MNI/minc-widgets/blob/master/volextents/volextents#L108

I'm putting together a test case for this. I would suggest you try this bit of magic on both the input minc files:

mincreshape \ -clobber \ -2 \ +direction \ -dimorder zspace,yspace,xspace \ -dimsize xspace=-1 \ -dimsize yspace=-1 \ -dimsize zspace=-1 \ input.mnc output.mnc

and see if the problem still exists. If not then it's dimension ordering and (likely) how mnc2nii detects this.

a

PS: If anyone has a more robust version of what I've used in volextents I'm also all ears!

On 20 July 2017 at 06:59, Gabriel A. Devenyi notifications@github.com wrote:

Running into a very weird bug in minc-toolkit/1.9.15:

Example 1: have brain1.mnc and brain1_mask.mnc if I do

mincmask brain1.mnc brain1_mask.mnc brain1_extracted.mnc mnc2nii brain1_extracted.mnc brain1_extracted.nii

I get NIFTI file that has the orientation re-arranged (i.e. no longer in the same space) If instead I do:

mincmath -mult brain1.mnc brain1_mask.mnc brain1_extracted.mnc mnc2nii brain1_extracted.mnc brain1_extracted.nii

Everything is fine

Example 2: have brain1_mask.mnc

mnc2nii brain1_mask.mnc brain1_mask.nii

Everything is fine.

mincmorph -successive DDDDDDDD brain1_mask.mnc brain1_mask_D.mnc mnc2nii brain1_mask_D.mnc brain1_mask_D.nii

Same problems as above.

Example of the swapped orientation problem:

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

rdvincent commented 7 years ago

mnc2nii is pretty buggy. I have been working on some comprehensive fixes, but it is surprisingly hard to catch all of the cases.

gdevenyi commented 7 years ago

@andrewjanke sadly, the mincreshape didn't fix it up :(

fristed commented 7 years ago

This seems to be exactly the same bug we report in issue #32 (last comment). Also, I think this bug arose with the fix done in November 2016, which addressed the issue of wrong start values. Running a mnc2nii from before the November 2016 fix does not have the bug with swapped orientation. In issue #32 (last comment) I provide an example, which behaves similarly as the example provided by Gabriel above. However, running an old (before Novmeber 2016) version of mnc2nii does not result in the error.

gdevenyi commented 7 years ago

Thanks for the hint @fristed, an older version of mnc2nii doesn't have this bug and otherwise converts everything fine.

gdevenyi commented 4 years ago

Fixed by #99