devel > gifti_valid_dims dim=1 check
Showing 1-5 of 5 posts
Display:
Results per page:
Mar 11, 2010  08:03 PM | Nick Schmansky
gifti_valid_dims dim=1 check
i noticed section 2.3.4.4 where it says that the last dimension shall never be one (except in the case of dim[0]), and i noticed that my freesurfer gifti io code was violating that rule. i have since fixed that. i have always called gifti_valid_gifti_image while reading and before writing, but i just noticed that the routine gifti_valid_dims does not check for the dim = 1 rule.

so my suggestion is, can gifti_valid_dims be modified to check for dim[] = 1 (except dim[0] is allowed to be 1) and return error?
Mar 11, 2010  10:03 PM | Richard Reynolds
Re: [gifti-devel forum] gifti_valid_dims dim=1 check
Under what circumstances were you violating the rule? It would be good to know in case it seems unecessarily restrictive.

Volume space shows a good example of why "violation" might be desired. A single slice dataset might get written as 2-D (with nz=0). But perhaps that would cause a "volumetric" program to fail to read it, when it would otherwise be okay (if nz were set to 1).

On the flip side, part of the question may be with respect to memory allocation. If the data is 4-D one might allocate 3 levels of pointers. But if the highest dimension size is 1, that is an unneeded complication to the coding.

Should we ponder this, or stick with the current wording, in which case I can make an update to the library? Does anyone else want to chime in?

- rick
Mar 11, 2010  11:03 PM | Nick Schmansky
Re: [gifti-devel forum] gifti_valid_dims dim=1 check
the circumstances were one that were not necessary. the code was making use of a local helper routine for reading 2D data to read 1D data (node-based), and so freesurfer was writing node data as 2D where the second dimension was '1'. since i just noticed that bit in the spec about the last dim not allowed to be '1', i changed the helper routine (which made the code cleaner), since i thought i might be breaking someone elses reader by writing files with a last dim of '1'.

so if there are valid reasons to have a last dim of '1', then maybe a check should not be made, or perhaps the spec should not mention that the last dim cannot be '1'. i dont have strong feelings on this, so its up to you i think.
Mar 12, 2010  02:03 PM | John Harwell
Re: [gifti-devel forum] gifti_valid_dims di

The decision to disallow a '1' for the last dimension was made during the April 10, 2008 phone conference.

From the summary of the phone conference:

Dimensionality:
This attribute will no longer include trailing dimensions of 1.
In other terms, if we have an Nx1 data array we should use:
dimensionality = 1;  dim0 =N
rather than:
dimensionality = 2;  dim0 = N;  dim1 = 1
Mar 12, 2010  08:03 PM | Richard Reynolds
Re: gifti_valid_dims dim=1 check
My feelings aren't strong, either. But I expect this to cause irritations either allowing it or not.

So for now I will change the library to be strict. Perhaps in the future we might decide to just have it whine a bit, rather than fail.

- rick