<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Install
bash
conda install -c mjirik -c conda-forge -c SimpleITK io3d sed3
Step1:  Alternative 2
Step2:  Download the data
Download the data and put it into the default directory ~/data/. It will take few minutes.
Step3:  Read intensity data
Step4:  Alternative 1
Step5:  Show one slice
Step6:  Show multiple slices
Step7:  Load segmentations
Step8:  See segmentations together with intensity image
Step9:  Interactive view
Step10:  Interactive view in external window (does not work from jupyter)
Step11:  Resize image
Before resize the z axis
Step12:  After resize
Step13:  Save data
<ASSISTANT_TASK:>
Python Code:
import io3d
import matplotlib.pyplot as plt
Explanation: Install
bash
conda install -c mjirik -c conda-forge -c SimpleITK io3d sed3
End of explanation
import io3d
import matplotlib.pyplot as plt
datap = io3d.read("http://home.zcu.cz/~mjirik/lisa/sample_data/nrn4.pklz")
plt.imshow(datap.data3d[5,:,:], cmap='gray')
Explanation: Alternative 2: read by url
End of explanation
io3d.datasets.download("3Dircadb1.1")
Explanation: Download the data
Download the data and put it into the default directory ~/data/. It will take few minutes.
End of explanation
datap = io3d.read_dataset("3Dircadb1", "data3d", 1)
# datap.data3d is equal to datap["data3d"]
datap["data3d"]
Explanation: Read intensity data
End of explanation
pth = io3d.datasets.get_dataset_path("3Dircadb1", "data3d", 1)
pth
datap = io3d.read(pth)
Explanation: Alternative 1: read data by filename
End of explanation
datap.data3d.shape
plt.imshow(datap.data3d[30,:,:], cmap='gray')
plt.colorbar()
Explanation: Show one slice
End of explanation
import sed3
sed3.show_slices(datap.data3d, slice_number=12)
Explanation: Show multiple slices
End of explanation
datap_liver = io3d.read_dataset("3Dircadb1", "liver", 1)
sed3.show_slices(datap_liver.data3d, slice_number=12)
Explanation: Load segmentations
End of explanation
sed3.show_slices(datap.data3d, slice_number=12, contour=datap_liver.data3d)
Explanation: See segmentations together with intensity image
End of explanation
sed3.ipy_show_slices(datap.data3d, contour=datap_liver.data3d)
Explanation: Interactive view
End of explanation
ed = sed3.sed3(datap.data3d, contour=datap_liver.data3d)
seeds = ed.show()
Explanation: Interactive view in external window (does not work from jupyter)
End of explanation
plt.figure(figsize=[10,8])
sed3.show_slices(datap.data3d, slice_number=6, axis=2)
print(datap.voxelsize_mm)
new_voxelsize_mm = [6,6,6]
data3d = io3d.image_manipulation.resize_to_mm(datap.data3d, voxelsize_mm=datap.voxelsize_mm, new_voxelsize_mm=new_voxelsize_mm)
Explanation: Resize image
Before resize the z axis:
End of explanation
plt.figure(figsize=[10,8])
sed3.show_slices(data3d, slice_number=6, axis=2)
# sed3.ipy_show_slices(data3d)# , contour=datap_liver.data3d)
Explanation: After resize:
End of explanation
io3d.write({"data3d":data3d, "voxelsize_mm":new_voxelsize_mm}, "resized.mhd")
dp = io3d.read("resized.mhd")
plt.imshow(dp.data3d[20,:,:], cmap='gray')
Explanation: Save data
End of explanation
<END_TASK>