3131 "M_LR_000260_L" : {"Prph" : 0.7 },
3232}
3333
34+
3435def plot_intensity_thresholds (input_dir , output_dir , cochlea , plot = False ):
3536 """Plot histograms for positive and negative populations of subtype markers based on thresholding.
3637 """
38+ os .makedirs (output_dir , exist_ok = True )
39+
3740 om_paths = [entry .path for entry in os .scandir (input_dir ) if "_om.json" in entry .name ]
3841 cochlea_str = "-" .join (cochlea .split ("_" ))
3942 om_paths = [p for p in om_paths if cochlea_str in p ]
@@ -44,8 +47,12 @@ def plot_intensity_thresholds(input_dir, output_dir, cochlea, plot=False):
4447 for stain , json_file in zip (stains , om_paths ):
4548 save_path = os .path .join (output_dir , f"{ cochlea } _{ stain } _thresholds.png" )
4649
47- with open (json_file , 'r' ) as myfile :
48- data = myfile .read ()
50+ try :
51+ with open (json_file , "r" ) as myfile :
52+ data = myfile .read ()
53+ except PermissionError as e :
54+ print (e )
55+ continue
4956 param_dicts = json .loads (data )
5057 center_strs = param_dicts ["center_strings" ]
5158 intensity_mode = param_dicts ["intensity_mode" ]
@@ -95,7 +102,7 @@ def plot_intensity_thresholds(input_dir, output_dir, cochlea, plot=False):
95102 ax [num ].legend ()
96103 ax [num ].set_title (center_str )
97104
98- if rows == 2 :
105+ if rows == 2 :
99106 for num , center_str in enumerate (center_strs ):
100107 seg_ids = param_dicts [center_str ]["seg_ids" ]
101108 threshold = CUSTOM_THRESHOLDS [cochlea ][stain ]
@@ -137,8 +144,8 @@ def main():
137144 parser .add_argument ("-c" , "--cochlea" , type = str , nargs = "+" , default = COCHLEAE , help = "Cochlea(e) to process." )
138145 parser .add_argument ("--figure_dir" , "-f" , type = str , required = True , help = "Output directory for plots." )
139146 parser .add_argument ("-i" , "--input_dir" , type = str ,
140- default = "/mnt/vast-nhr/projects/nim00007/data/moser/cochlea-lightsheet/mobie_project/cochlea-lightsheet/tables/Subtype_marker" ,
141- help = "Directory containing object measures of the cochleae." ) #noqa
147+ default = "/mnt/vast-nhr/projects/nim00007/data/moser/cochlea-lightsheet/mobie_project/cochlea-lightsheet/tables/Subtype_marker" , # noqa
148+ help = "Directory containing object measures of the cochleae." ) # noqa
142149
143150 args = parser .parse_args ()
144151 for cochlea in args .cochlea :
0 commit comments