From 87850ec84d2e14e01f63499053865f0bf30ea47b Mon Sep 17 00:00:00 2001 From: Victor Perez Meza Date: Mon, 4 Nov 2024 11:22:39 +0100 Subject: [PATCH] added illumination correction with basicpy --- macsima2mc/CLI.py | 6 ++++++ macsima2mc/macsima2mc.py | 11 +++++++++-- macsima2mc/tools.py | 4 ++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/macsima2mc/CLI.py b/macsima2mc/CLI.py index 46ed35f..a6b3ea9 100644 --- a/macsima2mc/CLI.py +++ b/macsima2mc/CLI.py @@ -29,6 +29,12 @@ def get_args(): help='string specifying the name of the reference marker' ) + parser.add_argument('-od', + '--output_dir', + default='raw', + help='string specifying the name of the reference marker' + ) + parser.add_argument('-ic', '--illumination_correction', action='store_true', diff --git a/macsima2mc/macsima2mc.py b/macsima2mc/macsima2mc.py index 4cf70a8..084be09 100644 --- a/macsima2mc/macsima2mc.py +++ b/macsima2mc/macsima2mc.py @@ -12,11 +12,18 @@ def main(args): input=args.input output=args.output ref=args.reference_marker - basicpy_corr=args.illumination_correction + basicpy_corr=args.illumination_correction + out_folder_name=args.output_dir + cycle_info=tools.cycle_info( input , macsima_pattern(version=2),ref_marker= ref) cycle_info=tools.append_metadata( cycle_info ) #cycle_info.to_csv( args.output / 'cycle_{c}_info.csv'.format(c=f'{6:03d}'), index=False ) - output_dirs=tools.create_stack( cycle_info, output ,ref_marker=ref,hi_exp=args.hi_exposure_only,ill_corr=basicpy_corr) + output_dirs=tools.create_stack( cycle_info, output , + ref_marker=ref, + hi_exp=args.hi_exposure_only, + ill_corr=basicpy_corr, + out_folder=out_folder_name + ) [mc_tools.write_markers_file(path) for path in output_dirs] diff --git a/macsima2mc/tools.py b/macsima2mc/tools.py index a534fa2..dc48e1c 100644 --- a/macsima2mc/tools.py +++ b/macsima2mc/tools.py @@ -184,7 +184,7 @@ def select_by_exposure(list_indices,exp_index=4,target='max'): return selected_indices -def create_stack(cycle_info_df,output_dir,ref_marker='DAPI',hi_exp=False,ill_corr=False,extended_outputs=False): +def create_stack(cycle_info_df,output_dir,ref_marker='DAPI',hi_exp=False,ill_corr=False,out_folder='raw',extended_outputs=False): if extended_outputs: out=outputs_dic() @@ -198,7 +198,7 @@ def create_stack(cycle_info_df,output_dir,ref_marker='DAPI',hi_exp=False,ill_cor acq_index=select_by_exposure(acq_index) for index in acq_index: - stack_output_dir=output_dir / cast_outdir_name(index) / 'staged' + stack_output_dir=output_dir / cast_outdir_name(index) / out_folder ( stack_output_dir ).mkdir(parents=True, exist_ok=True) group=acq_group.get_group(index) #use tile 1 as reference to determine the heigh and width of the tiles