Comments (13)
FYI it seems that inormalize
removes the direction_cosines if they are the default, which is how I ran into this problem.
from minc-tools.
Hi,
Can you post the mincheader outputs of a good vs bad file?
from minc-tools.
THe question about this bug is twofold:
- Is a minc file without direction cosines a valid minc file?
- What does https://github.com/BIC-MNI/minc-tools/blob/develop/conversion/nifti1/mnc2nii.c#L581-L582 return if a file has no direction cosine.
This could be classified as an inormalize bug depending on 1.
2. could be a corner case of the code. Will investigate.
from minc-tools.
Good file header (out.mnc)
hdf5 out {
dimensions:
xspace = 100 ;
yspace = 101 ;
zspace = 102 ;
variables:
double image(zspace, yspace, xspace) ;
image:version = "MINC Version 1.0" ;
image:vartype = "group________" ;
image:valid_range = 0., 1030199. ;
image:varid = "MINC standard variable" ;
image:complete = "true_" ;
image:dimorder = "zspace,yspace,xspace" ;
double image-min ;
image-min:version = "MINC Version 1.0" ;
image-min:vartype = "var_attribute" ;
image-min:varid = "MINC standard variable" ;
double image-max ;
image-max:version = "MINC Version 1.0" ;
image-max:vartype = "var_attribute" ;
image-max:varid = "MINC standard variable" ;
int xspace ;
xspace:version = "MINC Version 1.0" ;
xspace:vartype = "dimension____" ;
xspace:start = -40. ;
xspace:spacing = "regular__" ;
xspace:alignment = "centre" ;
xspace:direction_cosines = 1., 0., 0. ;
xspace:comments = "X increases from patient left to right" ;
xspace:units = "mm" ;
xspace:varid = "MINC standard variable" ;
xspace:length = 100 ;
xspace:step = 1. ;
int yspace ;
yspace:version = "MINC Version 1.0" ;
yspace:vartype = "dimension____" ;
yspace:start = -41. ;
yspace:spacing = "regular__" ;
yspace:alignment = "centre" ;
yspace:direction_cosines = 0., 1., 0. ;
yspace:comments = "Y increases from patient posterior to anterior" ;
yspace:units = "mm" ;
yspace:varid = "MINC standard variable" ;
yspace:length = 101 ;
yspace:step = 1. ;
int zspace ;
zspace:version = "MINC Version 1.0" ;
zspace:vartype = "dimension____" ;
zspace:start = -42. ;
zspace:spacing = "regular__" ;
zspace:alignment = "centre" ;
zspace:direction_cosines = 0., 0., 1. ;
zspace:comments = "Z increases from patient inferior to superior" ;
zspace:units = "mm" ;
zspace:varid = "MINC standard variable" ;
zspace:length = 102 ;
zspace:step = 1. ;
int acquisition ;
acquisition:version = "MINC Version 1.0" ;
acquisition:vartype = "group________" ;
acquisition:varid = "MINC standard variable" ;
int patient ;
patient:version = "MINC Version 1.0" ;
patient:vartype = "group________" ;
patient:varid = "MINC standard variable" ;
int study ;
study:version = "MINC Version 1.0" ;
study:vartype = "group________" ;
study:varid = "MINC standard variable" ;
// global attributes:
:ident = "stilley2:localhost.localdomain:2019.10.23.17.23.27:28228:1" ;
:minc_version = "2.4.04" ;
:history = "Wed Oct 23 17:23:27 2019>>> nii2mnc in.nii out.mnc\n",
"" ;
data:
image-min = 0 ;
image-max = 1030199 ;
xspace = 0 ;
yspace = 0 ;
zspace = 0 ;
acquisition = 0 ;
patient = 0 ;
study = 0 ;
}
bad file header (out_ndc.mnc)
hdf5 out_ndc {
dimensions:
xspace = 100 ;
yspace = 101 ;
zspace = 102 ;
variables:
double image(zspace, yspace, xspace) ;
image:version = "MINC Version 1.0" ;
image:vartype = "group________" ;
image:valid_range = 0., 1030199. ;
image:varid = "MINC standard variable" ;
image:complete = "true_" ;
image:dimorder = "zspace,yspace,xspace" ;
double image-min ;
image-min:version = "MINC Version 1.0" ;
image-min:vartype = "var_attribute" ;
image-min:varid = "MINC standard variable" ;
double image-max ;
image-max:version = "MINC Version 1.0" ;
image-max:vartype = "var_attribute" ;
image-max:varid = "MINC standard variable" ;
int xspace ;
xspace:version = "MINC Version 1.0" ;
xspace:vartype = "dimension____" ;
xspace:start = -40. ;
xspace:spacing = "regular__" ;
xspace:alignment = "centre" ;
xspace:comments = "X increases from patient left to right" ;
xspace:units = "mm" ;
xspace:varid = "MINC standard variable" ;
xspace:length = 100 ;
xspace:step = 1. ;
int yspace ;
yspace:version = "MINC Version 1.0" ;
yspace:vartype = "dimension____" ;
yspace:start = -41. ;
yspace:spacing = "regular__" ;
yspace:alignment = "centre" ;
yspace:comments = "Y increases from patient posterior to anterior" ;
yspace:units = "mm" ;
yspace:varid = "MINC standard variable" ;
yspace:length = 101 ;
yspace:step = 1. ;
int zspace ;
zspace:version = "MINC Version 1.0" ;
zspace:vartype = "dimension____" ;
zspace:start = -42. ;
zspace:spacing = "regular__" ;
zspace:alignment = "centre" ;
zspace:comments = "Z increases from patient inferior to superior" ;
zspace:units = "mm" ;
zspace:varid = "MINC standard variable" ;
zspace:length = 102 ;
zspace:step = 1. ;
int acquisition ;
acquisition:version = "MINC Version 1.0" ;
acquisition:vartype = "group________" ;
acquisition:varid = "MINC standard variable" ;
int patient ;
patient:version = "MINC Version 1.0" ;
patient:vartype = "group________" ;
patient:varid = "MINC standard variable" ;
int study ;
study:version = "MINC Version 1.0" ;
study:vartype = "group________" ;
study:varid = "MINC standard variable" ;
// global attributes:
:ident = "stilley2:localhost.localdomain:2019.10.23.17.23.27:28228:1" ;
:minc_version = "2.4.04" ;
:history = "Wed Oct 23 17:23:27 2019>>> nii2mnc in.nii out.mnc\n",
"" ;
data:
image-min = 0 ;
image-max = 1030199 ;
xspace = 0 ;
yspace = 0 ;
zspace = 0 ;
acquisition = 0 ;
patient = 0 ;
study = 0 ;
}
from minc-tools.
From here:
"direction_cosines - Numeric vector with 3 elements giving the direction cosines of the axes. Although axes are labeled x, y and z, they may in fact have a significantly different orientation - this attribute allows the direction relative to the true axes to be specified exactly. The vectors should be normalized unit vectors.
If these attributes are not present, they are assumed to have the following default values:
For xspace: (1, 0, 0), for yspace: (0, 1, 0), and for zspace: (0, 0, 1)"
So I believe the issue is 2, a corner case in mnc2nii
from minc-tools.
Additionally, I believe other programs besides inormalize do this, although I haven't tracked them down.
from minc-tools.
Thanks, my next stop was to check the file format docs.
We need to determine now if the problem is in mnc2nii or in miattget
.
from minc-tools.
Also, I've been bitten by this bug, here's my report #69
You figured out the root cause in terms of the difference in files :)
from minc-tools.
If you're interested, here's my temporary workaround to set the default direction_cosine
from minc-tools.
Working on this today, some updates:
miattget
does not modify the direction cosines if direction cosines are not specified in the minc file, it remains to be seen if the API should return the spec-specified values if none are in the file- The loop around this code which sets the cosines depends on the ordering of the dimensions in the minc file, so, for your files, "zspace,yspace,xspace", the direction cosines end up being defined as "0 0 1; 0 1 0; 1 0 0", which is wrong, it should be "1 0 0; 0 1 0; 0 0 1" and since
miattget
doesn't fix that. If I do,mincresahpe -dimorder xspace,yspace,zspace out_ndc.mnc reshape.mnc
,mnc2nii
correctly converts that file, despite there still being no direction cosines in the file.
So there are two possible solutions here
- Fix mnc2nii to always use the same x,y,z apparent ordering. This may have other interactions in the code, so I don't like it.
- Fix
miattget
to return the default cosines when none are in the file. I prefer this, but I need to go and learn where this code is.
from minc-tools.
miattget is low level call it's not supposed to know about default values of some attributes.
from minc-tools.
Thanks @vfonov I dug through the code and came to the same conclusion. I also found that mnc2nii uses minc1 API so ordering control isn't available.
As such I've been digging through the logic to see how I can fix nii2mnc
from minc-tools.
Fixed.
from minc-tools.
Related Issues (20)
- mnc2nii do not populate time_units header field in the NIfTI file HOT 5
- volume_stats: Assertion failed in CachedArray.cc AND seg fault in spline_smooth HOT 2
- dcm2mnc - phase encore direction information missing
- mnc2nii requires no transformation input? HOT 3
- Tempdir handling by various MINC tools HOT 1
- can't be built outside of toolkit due to missing cmake-modules/FindNIFTI.cmake HOT 2
- mnc2nii - Floating point exception (core dumped) error HOT 4
- nii2mnc doesn't seem to handle scl_slope and scl_inter properly
- Undefined behaviour in mincresample HOT 1
- 'Floating point exception' error using mnc2nii HOT 3
- Use min-tools on Win10 HOT 1
- mnc2nii not populating fields dim_info and slice_code in the NIfTI file HOT 2
- mnc2nii error - "floating point exception (core dumped)" HOT 5
- mincreshape modifies image-min when changing type HOT 1
- dcm2mnc binary versions HOT 4
- dcm2mnc issue with Siemens Prisma scanner (QSM and multi-echo fieldmap)
- dcm2mnc issue with GE MEDICAL SYSTEMS DISCOVERY MR750w HOT 2
- dcm2mnc issue with Philips Medical Systems Ingenia HOT 2
- mincstats does not honour order of command-line arguments
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from minc-tools.