[MINC-users] my student needs help with a scaling issue

Alex Zijdenbos zijdenbos at gmail.com
Fri Oct 19 15:09:26 EDT 2012


Hi Michel,

Looks to me that you are bitten by the difference between the "real"
values (which you would normally use, and which I assume
print_all_labels produces), and the "voxel" values? There is a linear
mapping between voxel values (as stored in the data type) and the real
values. This mapping is determined by the range of the data type of
the file, and the range of your data. In other words,

real = a*voxel + b

the advantage of this is that this way MINC can represent arbitrary
data ranges even though the data type may be limited; the disadvantage
is that discrete values, such as those used in atlases, may be mapped
to floating point values or show odd discretization effects like you
have here. For label volumes, the best is to remove the range scaling
(and make sure that the data type as enough resolution for your data).
Try this:

mincreshape -image_range 0 255 -valid_range 0 255 <in.mnc> <out.mnc>

which should remove the scaling (or rather, turn it into a one-to-one mapping).

-- A

On Fri, Oct 19, 2012 at 2:52 PM, Audette, Michel A. <maudette at odu.edu> wrote:
> Dear Minc users,
>
> my student Tanweer Rashid seems to be having a scaling issue related to reading a minc image.
>
> We are trying to read a digital deep-brain atlas graciously supplied by Mallar Chakravarty, and the voxel values that we get with minc routines are not quite consistent with the values that we get with the print_all_labels command run offline.
>
> See below, which features the output of print_all_labels (which looks reasonable), calls to miget_voxel_value() within Tanweer's program, and the source code of his that calls it.
>
> Can anyone spot something that we are doing wrong, and offer guidance on correcting Tanweer's bug?
>
> Thanks for your kind support.
>
> Michel
>
> Michel Audette, Ph.D.
> Assistant Professor,
> Department of Modeling, Simulation and Visualization Engineering,
> Old Dominion University,
> Norfolk, VA.
>
> ________________________________
> From: Tanweer Rashid [trash001 at odu.edu]
> Sent: Friday, October 19, 2012 11:49 AM
> To: Audette, Michel A.
> Subject: Code and results
>
> Results from print_all_labels():
> trash001 at LCARS:/usr/local/bin$ print_all_labels ~/Desktop/labels_on_colin_Nov2010_minc2.mnc
> Label: 1 933459
> Label: 2 1433227
> Label: 3 50946
> Label: 4 893200
> Label: 5 37056
> Label: 6 38333
> Label: 7 47522
> Label: 8 11922
> Label: 9 9238
> Label: 10 7369
> Label: 11 39738
> Label: 12 53097
> Label: 13 10502
> Label: 14 5301
> Label: 15 147
> Label: 16 33782
> Label: 17 918
> Label: 18 296
> Label: 19 504
> Label: 20 5060
> Label: 21 9438
> Label: 22 1739
> Label: 23 574
> Label: 24 138283
> Label: 25 16869
> Label: 26 22419
> Label: 27 5337
> Label: 28 10464
> Label: 29 9293
> Label: 30 1191
> Label: 31 201
> Label: 32 190
> Label: 33 513
> Label: 34 166
> Label: 35 71684
> Label: 36 11454
> Label: 37 72714
> Label: 38 153
>
>
> Results from using miget_voxel_value():
> Label 0: 26653169
> Label 1: 0
> Label 2: 933459
> Label 3: 0
> Label 4: 1433227
> Label 5: 0
> Label 6: 50946
> Label 7: 0
> Label 8: 670661
> Label 9: 222539
> Label 10: 20739
> Label 11: 16317
> Label 12: 3187
> Label 13: 35146
> Label 14: 25484
> Label 15: 22038
> Label 16: 4324
> Label 17: 7598
> Label 18: 1261
> Label 19: 7977
> Label 20: 0
> Label 21: 7369
> Label 22: 3099
> Label 23: 36639
> Label 24: 0
> Label 25: 53097
> Label 26: 0
> Label 27: 10502
> Label 28: 0
> Label 29: 5192
> Label 30: 109
> Label 31: 147
> Label 32: 0
> Label 33: 32633
> Label 34: 1149
> Label 35: 918
> Label 36: 0
> Label 37: 258
> Label 38: 38
> Label 39: 244
> Label 40: 260
> Label 41: 4869
>
> Code:
>     mihandle_t volume;
>     int result;
>
>     result = miopen_volume("/home/trash001/Desktop/labels_on_colin_Nov2010_minc2.mnc", MI2_OPEN_READ, &volume);
>     if (result == MI_ERROR) cout << "Error in opening MINC file. " << endl;
>
>     int labels[125];
>     for (int q = 0; q < 125; q++) labels[q] = 0;
>
>     unsigned long location[3];
>     double voxel;
>     for (int i = 0; i < 334; i++) {
>         for (int j = 0; j < 334; j++) {
>             for (int k = 0; k < 334; k++) {
>                 location[0] = i;
>                 location[1] = j;
>                 location[2] = k;
>
>                 result = miget_voxel_value(volume, location, 3, &voxel);
>                 if (result == MI_ERROR) cout << "Error in reading voxels" << endl;
>                 else {
>                     if (voxel >= 0 && voxel <= 123) {
>                         labels[(int)voxel] = labels[(int)voxel] + 1;
>                     }
>                     else if (voxel > 123) {
>                         labels[124] = labels[124] + 1;
>                     }
>                 }
>             }
>         }
>     }
>
> --
> Tanweer Rashid
> MSVE Dept.
> Old Dominion University
>
> ________________________________
>
> Spam<https://www.spamtrap.odu.edu/canit/b.php?i=01Id3Nqxx&m=7100c97e3076&t=20121019&c=s>
> Not spam<https://www.spamtrap.odu.edu/canit/b.php?i=01Id3Nqxx&m=7100c97e3076&t=20121019&c=n>
> Forget previous vote<https://www.spamtrap.odu.edu/canit/b.php?i=01Id3Nqxx&m=7100c97e3076&t=20121019&c=f>
> _______________________________________________
> MINC-users at bic.mni.mcgill.ca
> http://www.bic.mni.mcgill.ca/mailman/listinfo/minc-users
>


More information about the MINC-users mailing list