generated from mohsenhariri/template-python
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
747dbf6
commit 3e08139
Showing
18 changed files
with
145 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,4 @@ config | |
other | ||
env_linux_3.11 | ||
env_linux_3.10 | ||
env_linux_3.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ USER=mh | |
SSH=false | ||
PYPIU=mhariri | ||
PYPIP=password | ||
|
||
PYPI_TOKEN=token | ||
dataset=/mnt/rstor/CSE_BME_AXM788/home/mxh1029/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
MedViz | ||
=============== | ||
|
||
Documentation_ -- GitHub_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import medviz | ||
|
||
medviz.layered_plot(image_path="dataset/1-1.nii", mask_paths=["dataset/small_bowel.nii", "dataset/1-1-label.nii"], mask_colors=["red", "yellow"], title="Layered Plot") | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .layered_plot import * |
This file was deleted.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import numpy as np | ||
import nibabel as nib | ||
import matplotlib.pyplot as plt | ||
from matplotlib.widgets import Slider | ||
|
||
# Load the CT scan and mask images | ||
ct_img = nib.load("dataset/1-1.nii") | ||
mask_img1 = nib.load("dataset/small_bowel.nii") | ||
mask_img2 = nib.load("dataset/1-1-label.nii") | ||
|
||
# Get the image data and mask data | ||
ct_data = ct_img.get_fdata() | ||
mask_data1 = mask_img1.get_fdata() | ||
mask_data2 = mask_img2.get_fdata() | ||
|
||
# Rotate the images 90 degrees clockwise | ||
ct_data = np.rot90(ct_data, axes=(1, 0)) | ||
mask_data1 = np.rot90(mask_data1, axes=(1, 0)) | ||
mask_data2 = np.rot90(mask_data2, axes=(1, 0)) | ||
|
||
# Create a figure with a slider | ||
fig, ax = plt.subplots() | ||
plt.subplots_adjust(bottom=0.25) | ||
ax.imshow(ct_data[:, :, ct_data.shape[2]//2], cmap='gray') | ||
ax.contour(mask_data1[:, :, mask_data1.shape[2]//2], colors='r', levels=[0.5]) | ||
ax.contour(mask_data2[:, :, mask_data2.shape[2]//2], colors='b', levels=[0.5]) | ||
ax.set_xlabel('Slice Number') | ||
slider_ax = plt.axes([0.2, 0.1, 0.6, 0.03]) | ||
slider = Slider(slider_ax, 'Slice', 0, ct_data.shape[2]-1, valinit=ct_data.shape[2]//2, valstep=1) | ||
|
||
# Update the plot when the slider value changes | ||
def update(val): | ||
slice_num = int(slider.val) | ||
ax.clear() | ||
ax.imshow(ct_data[:, :, slice_num], cmap='gray') | ||
ax.contour(mask_data1[:, :, slice_num], colors='r', levels=[0.5]) | ||
ax.contour(mask_data2[:, :, slice_num], colors='y', levels=[0.5]) | ||
ax.set_xlabel('Slice Number') | ||
|
||
slider.on_changed(update) | ||
plt.show() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import numpy as np | ||
import nibabel as nib | ||
import matplotlib.pyplot as plt | ||
from matplotlib.widgets import Slider | ||
|
||
|
||
|
||
|
||
|
||
def layered_plot(image_path, mask_paths, mask_colors=["red", "yellow"], title="Layered Plot"): | ||
print("Loading images...") | ||
# Load the CT scan and mask imagesfsdf | ||
ct_img = nib.load(image_path) | ||
mask_img1 = nib.load(mask_paths[0]) | ||
mask_img2 = nib.load(mask_paths[1]) | ||
|
||
# Get the image data and mask data | ||
ct_data = ct_img.get_fdata() | ||
mask_data1 = mask_img1.get_fdata() | ||
mask_data2 = mask_img2.get_fdata() | ||
|
||
# Rotate the images 90 degrees clockwise | ||
ct_data = np.rot90(ct_data, axes=(1, 0)) | ||
mask_data1 = np.rot90(mask_data1, axes=(1, 0)) | ||
mask_data2 = np.rot90(mask_data2, axes=(1, 0)) | ||
|
||
# Create a figure with a slider | ||
fig, ax = plt.subplots() | ||
plt.subplots_adjust(bottom=0.25) | ||
ax.imshow(ct_data[:, :, ct_data.shape[2]//2], cmap='gray') | ||
ax.contour(mask_data1[:, :, mask_data1.shape[2]//2], colors='r', levels=[0.5]) | ||
ax.contour(mask_data2[:, :, mask_data2.shape[2]//2], colors='b', levels=[0.5]) | ||
ax.set_xlabel('Slice Number') | ||
slider_ax = plt.axes([0.2, 0.1, 0.6, 0.03]) | ||
slider = Slider(slider_ax, 'Slice', 0, ct_data.shape[2]-1, valinit=ct_data.shape[2]//2, valstep=1) | ||
|
||
# Update the plot when the slider value changes | ||
def update(val): | ||
slice_num = int(slider.val) | ||
ax.clear() | ||
ax.imshow(ct_data[:, :, slice_num], cmap='gray') | ||
ax.contour(mask_data1[:, :, slice_num], colors='r', levels=[0.5]) | ||
ax.contour(mask_data2[:, :, slice_num], colors='y', levels=[0.5]) | ||
ax.set_xlabel('Slice Number') | ||
|
||
slider.on_changed(update) | ||
plt.show() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.