<jupyter_start><jupyter_text>Image Processing using SimpleITK  Clear scene and load sample data set using SimpleITK<jupyter_code>import JupyterNotebooksLib as slicernb

import SimpleITK as sitk
import sitkUtils as su

# Clear scene
slicer.mrmlScene.Clear(False)

# Load 3D image using SimpleITK
reader = sitk.ImageFileReader()
reader.SetFileName("data/MRBrainTumor1.nrrd")
image = reader.Execute()<jupyter_output><empty_output><jupyter_text>Display SimpleITK image<jupyter_code>volumeNode = su.PushVolumeToSlicer(image)

# Prevent automatic brightness/contrast update to make the processed images easier to compare
volumeNode.GetDisplayNode().SetAutoWindowLevel(False)

# Set up view layout
slicer.app.layoutManager().setLayout(slicer.vtkMRMLLayoutNode.SlicerLayoutFourUpView)
# Set up slice views
slicer.util.setSliceViewerLayers(background=volumeNode, fit=True)
# Set up volume rendering
displayNode = slicer.modules.volumerendering.logic().CreateDefaultVolumeRenderingNodes(volumeNode)
displayNode.GetVolumePropertyNode().Copy(slicer.modules.volumerendering.logic().GetPresetByName('MR-Default'))
slicer.util.resetThreeDViews()

# Display views
slicernb.ViewDisplay()<jupyter_output><empty_output><jupyter_text>Process image and show results<jupyter_code>blurFilter = sitk.SmoothingRecursiveGaussianImageFilter()
blurFilter.SetSigma(3.0)
blurredImage = blurFilter.Execute(image)

su.PushVolumeToSlicer(blurredImage, targetNode=volumeNode)
slicernb.ViewDisplay()<jupyter_output><empty_output><jupyter_text>Process the image using another filter and show results<jupyter_code>blurFilter2 = sitk.CurvatureFlowImageFilter()
blurFilter2.SetNumberOfIterations(5)
blurFilter2.SetTimeStep(0.15)
blurredImage2 = blurFilter2.Execute(image)

su.PushVolumeToSlicer(blurredImage2, targetNode=volumeNode)
slicernb.ViewDisplay()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08829902491874322, 'fraction_numerical': 0.007583965330444204, 'mean_word_length': 9.801169590643275, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '22390', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 627, 'n_tokens_neox': 606, 'n_words': 102, 'path': '03_Image_Processing_using_SimpleITK.ipynb', 'repo_name': 'FaizanSiddiqui91/slicer_notebook_test', 'size': '1846'}