open-discussion
open-discussion > RE: use the package of MRIcroGL in common python coding and problem about remove haze in scripting
Aug 2, 2020 11:08 AM | Chris Rorden
RE: use the package of MRIcroGL in common python coding and problem about remove haze in scripting
Consider the command "Remove Haze with Options"
1. Segment the image with a multi-level Otsu's Method
https://en.wikipedia.org/wiki/Otsu%27s_m...
https://scikit-image.org/docs/dev/auto_e...
The user selects a threshold from 1..5
a. Level 1: Compute Otsu 4 level, choose darkest as "air"
b. Level 2: Compute Otsu 3 level, choose darkest as "air"
c. Level 3: Compute Otsu 2 level, choose darkest as "air"
d. Level 4: Compute Otsu 3 level, choose all but brightest as "air"
e. Level 5: Compute Otsu 4 level, choose all but brightest as "air"
Air voxels are set to darkest value in volume.
2. (Optional) If the user selects "Only largest object", we compute connectivity based on 6 neighbors (e.g. to be part of a cluster, a neighbor must share a face, sharing an edge or corner does not count). Voxels that are not part of the largest cluster are set to the darkest value in the volume.
3. (Optional) If the user chooses to "Smooth Edges" a mask is generated that contains surviving voxels that are near air (as defined by 3 dilations). Voxels in this region are blurred with the neighbors. The goal here is to ensure that voxels near the air-brain surface do not appear jagged, while interior voxels retain their details.
4. The size of the surviving clusters is dilated by two voxels, and the "air" voxels that are near the object get their original values. The goal here is to feather the edges and preserve partial volume effects.
The MRIcroGL scripting function "extract" can perform this.
extract (built-in function):
extract(|b,s,t) -> Remove haze from background image. Blur edges (b: 0=no, 1=yes, default), single object (s: 0=no, 1=yes, default), threshold (t: 1..5=high threshold, 5 is default, higher values yield larger objects)
And it is easy to call MRIcroGL scripts from Python or BASH scripts. However, the current scripting language only has commands to save bitmaps, not modified NIfTI images (e.g. you can not invoke the File/SaveNIfTI menu item from a script). I will consider adding this to a future release. However, you can easily emulate this function using a Python script using the recipe I provide above.
1. Segment the image with a multi-level Otsu's Method
https://en.wikipedia.org/wiki/Otsu%27s_m...
https://scikit-image.org/docs/dev/auto_e...
The user selects a threshold from 1..5
a. Level 1: Compute Otsu 4 level, choose darkest as "air"
b. Level 2: Compute Otsu 3 level, choose darkest as "air"
c. Level 3: Compute Otsu 2 level, choose darkest as "air"
d. Level 4: Compute Otsu 3 level, choose all but brightest as "air"
e. Level 5: Compute Otsu 4 level, choose all but brightest as "air"
Air voxels are set to darkest value in volume.
2. (Optional) If the user selects "Only largest object", we compute connectivity based on 6 neighbors (e.g. to be part of a cluster, a neighbor must share a face, sharing an edge or corner does not count). Voxels that are not part of the largest cluster are set to the darkest value in the volume.
3. (Optional) If the user chooses to "Smooth Edges" a mask is generated that contains surviving voxels that are near air (as defined by 3 dilations). Voxels in this region are blurred with the neighbors. The goal here is to ensure that voxels near the air-brain surface do not appear jagged, while interior voxels retain their details.
4. The size of the surviving clusters is dilated by two voxels, and the "air" voxels that are near the object get their original values. The goal here is to feather the edges and preserve partial volume effects.
The MRIcroGL scripting function "extract" can perform this.
extract (built-in function):
extract(|b,s,t) -> Remove haze from background image. Blur edges (b: 0=no, 1=yes, default), single object (s: 0=no, 1=yes, default), threshold (t: 1..5=high threshold, 5 is default, higher values yield larger objects)
And it is easy to call MRIcroGL scripts from Python or BASH scripts. However, the current scripting language only has commands to save bitmaps, not modified NIfTI images (e.g. you can not invoke the File/SaveNIfTI menu item from a script). I will consider adding this to a future release. However, you can easily emulate this function using a Python script using the recipe I provide above.
Threaded View
Title | Author | Date |
---|---|---|
Lance Liu | Jun 26, 2020 | |
Chris Rorden | Jun 26, 2020 | |
Lance Liu | Jun 28, 2020 | |
Chris Rorden | Jun 28, 2020 | |
Lance Liu | Aug 2, 2020 | |
Chris Rorden | Aug 2, 2020 | |
Lance Liu | Aug 3, 2020 | |
Chris Rorden | Aug 3, 2020 | |
Chris Rorden | Jun 28, 2020 | |