jfcabana / omg_dosimetry

Optimized Multichannel Gafchromic Dosimetry
https://omg-dosimetry.readthedocs.io/en/latest/
MIT License
7 stars 2 forks source link

New discard_small_clusters() #51

Closed LuisOlivaresJ closed 2 months ago

LuisOlivaresJ commented 2 months ago

Added discard_small_clusters() method in BaseImage class to remove small clusters.

Additionally, I have noticed that plot() method form BaseImage now uses origin='upper', but plot_clusters() does not. Below is an example of the output figure when plot_clusters() is called. As can be seen, the image and the scatter are inverted.

Script example:

from omg_dosimetry.tiff2dose import Gaf
from omg_dosimetry import tiff2dose
import matplotlib.pyplot as plt

# Load demo LUT
path_to_lut_file = tiff2dose.from_demo_lut()

# Load folder to demo tif file
path_to_tif_folder = tiff2dose.from_demo_image()

# Gaf init.
fit_type = 'rational'
clip = 500
gaf = Gaf(
    path_to_tif_folder,
    lut_file=path_to_lut_file,
    fit_type=fit_type,
    clip=clip,
    img_filt=3,
    crop_edges=0.1,
)

clusters = gaf.dose_opt.detect_clusters()

print(len(gaf.dose_opt.clusters))  # 388
gaf.dose_opt.discard_small_clusters(minimum_length=2)
print(len(gaf.dose_opt.clusters))  # 13

gaf.dose_opt.plot_clusters()

Screenshot from 2024-05-09 13-04-48

jfcabana commented 2 months ago

I needed to change the origin to have the dose and isodoses plots in the same orientation on my side,. image image

LuisOlivaresJ commented 2 months ago

Ok. I do not have more comments.