<jupyter_start><jupyter_text>Example usage of ResultsDrawer class<jupyter_code>%pylab inline
from IPython.display import display

import logging
logging.basicConfig()
logger = logging.getLogger()
logger.setLevel(logging.WARNING)

import sys, os

# os.system("python -m io3d -l 3Dircadb1.1")
DATA_PATH = "3Dircadb1.1/PATIENT_DICOM"
import io3d

#PKG_PATH = "~/projects/bodynavigation"
PKG_PATH = "~/Programming/Sources/bodynavigation"
sys.path.append(os.path.expanduser(PKG_PATH))
from bodynavigation.results_drawer import ResultsDrawer
from bodynavigation.organ_detection import OrganDetection<jupyter_output>Populating the interactive namespace from numpy and matplotlib<jupyter_text>Produce some data to test with<jupyter_code>data3d, metadata = io3d.datareader.read(io3d.datasets.join_path(DATA_PATH), dataplus_format=False)
voxelsize = metadata["voxelsize_mm"]
obj = OrganDetection(data3d, voxelsize)
masks = [ obj.getPart(p) for p in ["bones","lungs","kidneys"] ]
bones_stats = obj.analyzeBones()
points = [bones_stats["spine"], bones_stats["hips_start"]]<jupyter_output>WARNING:io3d.dcmreaddata:Estimating SliceLocation wiht image number and SliceThickness
WARNING:io3d.dcmreaddata:Estimating SliceLocation wiht image number and SliceThickness
WARNING:io3d.dcmreaddata:Estimating SliceLocation wiht image number and SliceThickness
WARNING:io3d.dcmreaddata:Estimating SliceLocation wiht image number and SliceThickness
WARNING:io3d.dcmreaddata:Problem with tag SeriesDescription, SeriesNumber: 
WARNING:io3d.dcmreaddata:Problem with tag ImageComments<jupyter_text>BasicTransparent and overlapping:<jupyter_code>rd = ResultsDrawer(default_volume_alpha = 100)
img = rd.drawImageAutocolor(data3d, voxelsize, volumes = masks, points = points)
display(img) #img.show()<jupyter_output><empty_output><jupyter_text>Solid with depth:<jupyter_code>rd = ResultsDrawer(mask_depth = True, default_volume_alpha = 255)
img = rd.drawImageAutocolor(data3d, voxelsize, volumes = masks, points = points)
display(img) #img.show()<jupyter_output><empty_output><jupyter_text>Drawn image can be shown with: img.show()Drawn image can be saved with: img.save("./img.png")  Advanced Inicialization options These values are used for transformation of dicom values to  value range.<jupyter_code>data3d_forced_min = -1024; data3d_forced_max = 1024<jupyter_output><empty_output><jupyter_text>These are default values that are used if user does not give them.<jupyter_code>default_volume_alpha = 100; default_point_alpha = 255; default_point_border = (0,0,0); default_point_size = 5<jupyter_output><empty_output><jupyter_text>Following enables displaying depth of segmented data, enables only drawing parts of masks that are not hidden behind other masks, and defines how fast does color darken in depth mode. (mask_depth_sort is forced True if mask_depth=True)<jupyter_code>mask_depth = False; mask_depth_sort = False; mask_depth_scale = 0.75<jupyter_output><empty_output><jupyter_text>Custom colors and point sizes<jupyter_code>volume_sets = []
volume_sets.append([obj.getPart("bones"), {"color":(0,0,255)}])
volume_sets.append([obj.getPart("kidneys"), {"color":(0,255,0,255)}])

point_sets = []
point_sets.append([bones_stats["spine"], {"color":(255,0,0), "size":3}])
point_sets.append([bones_stats["hips_start"], {"color":(0,128,128), "size":7, "border":(255,255,0)}])

rd = ResultsDrawer(default_volume_alpha = 128)
img = rd.drawImage(data3d, voxelsize, volume_sets = volume_sets, point_sets = point_sets)
display(img) #img.show()<jupyter_output><empty_output><jupyter_text>You can also use predefined RGB/RGBA colors:<jupyter_code>print( rd.getRGBA(0) )
print( rd.getRGBA(0, a=128) )<jupyter_output>(43, 0, 255)
(43, 0, 255, 128)
{'fraction_non_alphanumeric': 0.11323806956052844, 'fraction_numerical': 0.028848746292801295, 'mean_word_length': 8.73753280839895, 'pattern_counts': {'":': 7, '<': 34, '<?xml version=': 0, '>': 34, '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': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '569654', 'license': 'MIT', 'n_tokens_mistral': 1381, 'n_tokens_neox': 1271, 'n_words': 270, 'path': 'examples/results_drawer.ipynb', 'repo_name': 'mjirik/bodynavigation', 'size': '3709'}