# How to apply intensity normalization to MRI(.mha) with Slicer

**URL:** https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690
**Category:** Support
**Created:** [December 19, 2017, 2:58pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690 "2017-12-19T14:58:49Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![hei6775](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hei6775](https://discourse.slicer.org/u/hei6775)
#### Post date: [December 19, 2017, 2:58pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/1 "2017-12-19T14:58:49Z")

</div>

Hi,  
I am working with a project of brain segmentation and need to preprocess my MRI(from BRATS2015). I have applied N4ITK within Slicer, but I cannot find out how to apply intensity normalization with Slicer 4.6.2. Or is there any normal ways I can use to normalize my MRI.  
And,I want to look the histogram of MRI 3D image.how to do it?  
Thank you all!!!

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [December 19, 2017, 4:19pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/2 "2017-12-19T16:19:51Z")

</div>

You can use SimpleFilters and the NormalizeImageFilter and then look at the histogram in the Volumes module.

HTH,  
Steve

---

<div class="post-metadata">

### Author: ![hei6775](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hei6775](https://discourse.slicer.org/u/hei6775)
#### Post date: [December 20, 2017, 9:22am UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/3 "2017-12-20T09:22:47Z")

</div>

hi,i apply on my files.But the result is not my want to get.I want to get like:

 ![01](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/9/1/9126229b4f4b109b447f517386c24cc2a6ae63e7.png)

---

<div class="post-metadata">

### Author: ![hei6775](https://avatars.discourse-cdn.com/v4/letter/h/a6a055/32.png) [@hei6775](https://discourse.slicer.org/u/hei6775)
#### Post date: [December 20, 2017, 9:24am UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/4 "2017-12-20T09:24:37Z")

</div>

yes,but it has some problem

---

<div class="post-metadata">

### Author: ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)
#### Post date: [December 20, 2017, 2:41pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/5 "2017-12-20T14:41:56Z")

</div>

If you want to normalize all the images to the same range then you’ll need to write a small script. There’s not built-in tool that does that. If you are comfortable writing a script but want specific suggestions let us know.

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [December 20, 2017, 3:36pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/6 "2017-12-20T15:36:39Z")

</div>

For more refined, interactive plotting, you can create a histogram and show in a plot view, as it is done in this example: [Documentation/Nightly/ScriptRepository - Slicer Wiki](https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Create_histogram_plot_of_a_volume)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/a/bacf5bb20045a5d547179ad820d35156b7084fa6.jpeg)

---

<div class="post-metadata">

### Author: ![kayarre](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/kayarre/32/3606_2.png) [@kayarre](https://discourse.slicer.org/u/kayarre)
#### Post date: [September 10, 2018, 6:12pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/7 "2018-09-10T18:12:50Z")

</div>

This is very helpful, how would you suggest doing this if you want compare the histograms of multiple images as in the images above?

basically make a loop around this for each image? is there a way to get the histogram that is already shown in the volumes module and plot that blue line for each image?

---

<div class="post-metadata">

### Author: ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)
#### Post date: [September 10, 2018, 6:24pm UTC](https://discourse.slicer.org/t/how-to-apply-intensity-normalization-to-mri-mha-with-slicer/1690/8 "2018-09-10T18:24:48Z")

</div>

> [@kayarre](#):
>
> how would you suggest doing this if you want compare the histograms of multiple images as in the images above?

You can add any number of series in a chart. So, yes, you can just iterate through all relevant volume nodes, create a plot series for each, and add it to the chart.

> [@kayarre](#):
>
> is there a way to get the histogram that is already shown in the volumes module

Volumes module only computes histogram for the currently selected volume and I’m not sure that even this histogram is exposed through a public API.

Since you can compute the histogram in near-zero time, with a single line of code, with full control of histogram bins, it makes sense to follow the method shown in the example Python script.

Note that in recent nightly builds, `slicer.util.plot` function can even furher simplify the syntax:

```
# Get a volume node
import SampleData
volumeNode = SampleData.SampleDataLogic().downloadMRHead()

# Plot histogram
import numpy as np
histogram = np.histogram(arrayFromVolume(volumeNode), bins=50)
chartNode = plot(histogram, xColumnIndex = 1)

```
