pynrrd icon indicating copy to clipboard operation
pynrrd copied to clipboard

oldmin and oldmax support

Open tashrifbillah opened this issue 7 years ago • 9 comments

Nifti1 has scl_slope and scl_inter. The equivalent attributes in the Nrrd are oldmin and oldmax. However, we don't have support for oldmin and oldmax if they are present in intensity calibrated images (for relative intensity images, they are ignored), do we? If we don't have, then I am developing support for it.

tashrifbillah avatar Mar 04 '19 15:03 tashrifbillah

Unless I'm misunderstanding the question, pynrrd should read the oldmin, old min, oldmax, and old max attributes as double's. See the code here: https://github.com/mhe/pynrrd/blob/master/nrrd/reader.py#L89

As far as I can tell, they should be read correctly.

addisonElliott avatar Mar 04 '19 19:03 addisonElliott

I see, so you left it up to the user to properly scale their data, right? However, NIBABEL scales it automatically before reporting.

tashrifbillah avatar Mar 04 '19 19:03 tashrifbillah

Oh I understand! Are you wanting it scaled between 0.0f and 1.0f?

This is essentially what you need then?

(data - oldmin) / (oldmax - oldmin)

If so, do you think it's worthwhile to include that in the pynrrd library or leave it up to the user?

addisonElliott avatar Mar 04 '19 20:03 addisonElliott

@tashrifbillah ping. Am I on the right track? What are your thoughts on this?

addisonElliott avatar Mar 07 '19 18:03 addisonElliott

Label: Follow Up Required Assign: @tashrifbillah

I am organizing the issue in a better way. Let's keep it open, I shall follow up soon.

tashrifbillah avatar Mar 07 '19 18:03 tashrifbillah

Are you wanting it scaled between 0.0f and 1.0f?

Negative, we don't want to normalize data, rather scale data properly taking into account oldmin and oldmax.

So, how do we do that using math?

Given oldmin, oldmax, datatype:

oldmin=(datatype_min)*scl_slope + scl_inter
oldmax= (datatype_max)*scl_slope + scl_inter

then, we should solve the above equations to find scl_slope and scl_inter. Then, the reported data should be:

scaled_data= raw_data*scl_slope+scl_inter

You can take a look at my issue on ITK where I justified reporting scaled data like NIBABEL and FSLview.

tashrifbillah avatar Mar 11 '19 21:03 tashrifbillah

👍 I'm with you, all makes sense.

This should be doable from this library via the custom header fields options. Not sure this is worth being built-in functionality personally. If anything, we could add a helper function that users can utilize.

What are your thoughts?

addisonElliott avatar Mar 11 '19 21:03 addisonElliott

Hello, do you know how to get the coronal plane, why can I just get the cross section?

Chida15 avatar May 13 '19 13:05 Chida15

@Chida15 , do you mind opening a separate issue on your question? This thread is for other issue we are trying to solve.

tashrifbillah avatar May 13 '19 14:05 tashrifbillah