Skip to content

Commit

Permalink
pkg publish
Browse files Browse the repository at this point in the history
  • Loading branch information
mohsenhariri committed Apr 19, 2023
1 parent 747dbf6 commit 3e08139
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 522 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ config
other
env_linux_3.11
env_linux_3.10
env_linux_3.9
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ USER=mh
SSH=false
PYPIU=mhariri
PYPIP=password

PYPI_TOKEN=token
dataset=/mnt/rstor/CSE_BME_AXM788/home/mxh1029/
16 changes: 9 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ PROTOCOL := HTTP
endif
URL := $(PROTOCOL)://$(HOST):$(PORT)

.PHONY: env test all dev clean dev pyserve gen-commands $(SRC) $(DIST) $(BUILD)
.PHONY: env test all dev clean dev pyserve gen-commands $(SRC) $(DIST) $(BUILD) py.make

.DEFAULT_GOAL := test

Expand Down Expand Up @@ -111,10 +111,12 @@ pkg-check:
$(PY) -m pip install --upgrade twine
twine check dist/*

pkg-publish-test:
twine upload --config-file .pypirc.test -r testpypi dist/* --verbose

pkg-publish:
pkg-publish-test: .pypirc
twine upload --config-file .pypirc -r testpypi dist/* --verbose


pkg-publish: .pypirc
twine upload --config-file .pypirc dist/* --verbose

pkg-flit-init:
Expand Down Expand Up @@ -171,9 +173,9 @@ type-prod:
script-upgrade:
./scripts/upgrade_dependencies.sh

gen-commands:
$(foreach file,$(PY_FILES),$(shell echo "\n$(subst /,-,$(subst $(SRC)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> py.make))

temp-rm:
rm py.make

gen-commands:
gen-commands: temp-rm
$(foreach file,$(PY_FILES),$(shell echo "\n$(subst /,-,$(subst $(SRC)/,,$(basename $(file)))):\n\t\t$(PY) $(file)" >> py.make))
35 changes: 27 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
# MedViz

## Usage

Install the package using pip

```bash
pip install medviz
```
Import the package and use the layered_plot function

```python
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")
```

## Development

### Setup

- make env
- source env_platform_ver/bin/activate
- make
- make check
- make pireq
### Required packages

## Required packages
- Numpy
- Matplotlib
- Nibabel

### Slider- To do

- [x] Max
Expand All @@ -12,11 +38,4 @@



## Development

make env
source env_platform_ver/bin/activate
make
make check
make pireq

2 changes: 0 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
MedViz
===============

Documentation_ -- GitHub_

5 changes: 5 additions & 0 deletions examples/image_mask.py
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")


1 change: 1 addition & 0 deletions medviz/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .layered_plot import *
9 changes: 0 additions & 9 deletions medviz/example.py

This file was deleted.

Empty file removed medviz/hist_path.py
Empty file.
41 changes: 41 additions & 0 deletions medviz/image_masks_axial.py
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()
139 changes: 0 additions & 139 deletions medviz/layered.py

This file was deleted.

47 changes: 47 additions & 0 deletions medviz/layered_plot.py
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()
27 changes: 0 additions & 27 deletions medviz/reader.py

This file was deleted.

Loading

0 comments on commit 3e08139

Please sign in to comment.