In this small project, I will show you how you can use Streamlit and VTK to create a simple 3D visualizer that allows you to upload and visualize NIFTI
files.
pip install streamlit
pip install streamlit-lottie
pip install vtk
pip install ipywidgets
pip install itkwidgets
pip install requests
pip install glob2
pip install pytest-shutil
If you don't know how to host the application online, then you can host it and run it locally. These are the steps:
- Clone the repository:
git clone https://github.com/amine0110/medical-visualization-with-streamlit
- Install the Packages discussed above.
- Run the command:
streamlit run .\main.py
If you are looking only to visualize the NIFTI files without having all the other options, then this is the part that you need to focus on:
path_to_file = glob(f'{temp_data_directory}/*.nii.gz')
if path_to_file:
with st.container():
reader = vtk.vtkNIFTIImageReader()
reader.SetFileName(path_to_file[0])
reader.Update()
view_width = 1800
view_height = 1600
snippet = embed.embed_snippet(views=view(reader.GetOutput()))
html = embed.html_template.format(title="", snippet=snippet)
components.html(html, width=view_width, height=view_height)
Stay up-to-date on the latest in computer vision and medical imaging! Subscribe to my newsletter now for insights and analysis on the cutting-edge developments in this exciting field.
Learn how to effectively manage and process DICOM files in Python with our comprehensive course, designed to equip you with the skills and knowledge you need to succeed.