@@ -600,30 +600,28 @@ def run(self, workspace):
600600 # Save the image to the Docker mounted directory
601601 skimage .io .imsave (temp_img_path , x_data )
602602
603- cmd = f"""
604- { docker_path } run --rm -v { temp_dir } :/data
605- { self .docker_image .value }
606- { '--gpus all' if self .use_gpu .value else '' }
607- cellpose
608- --dir /data/img
609- { '--pretrained_model ' + self .mode .value if self .mode .value != 'custom' else '--pretrained_model /data/model/' + model_file }
610- --chan { channels [0 ]}
611- --chan2 { channels [1 ]}
612- --diameter { diam }
613- { '--net_avg' if self .use_averaging .value else '' }
614- { '--do_3D' if self .do_3D .value else '' }
615- --anisotropy { anisotropy }
616- --flow_threshold { self .flow_threshold .value }
617- --cellprob_threshold { self .cellprob_threshold .value }
618- --stitch_threshold { self .stitch_threshold .value }
619- --min_size { self .min_size .value }
620- { '--invert' if self .invert .value else '' }
621- { '--exclude_on_edges' if self .remove_edge_masks .value else '' }
622- --verbose
623- """
624-
603+ cmd = [docker_path , 'run' , '--rm' , '-v' , f'{ temp_dir } :/data' , self .docker_image .value ]
604+ if self .use_gpu .value :
605+ cmd += ['--gpus' , 'all' ]
606+ cmd += ['cellpose' , '--verbose' , '--dir' , '/data/img' , '--pretrained_model' ]
607+ if self .mode .value != 'custom' :
608+ cmd += [self .mode .value ]
609+ else :
610+ cmd += ['/data/model/' + model_file ]
611+ cmd += ['--chan' , str (channels [0 ]), '--chan2' , str (channels [1 ]), '--diameter' , str (diam )]
612+ if self .use_averaging .value :
613+ cmd += ['--net_avg' ]
614+ if self .do_3D .value :
615+ cmd += ['--do_3D' ]
616+ cmd += ['--anisotropy' , str (anisotropy ), '--flow_threshold' , str (self .flow_threshold .value ), '--cellprob_threshold' ,
617+ str (self .cellprob_threshold .value ), '--stitch_threshold' , str (self .stitch_threshold .value ), '--min_size' , str (self .min_size .value )]
618+ if self .invert .value :
619+ cmd += ['--invert' ]
620+ if self .remove_edge_masks .value :
621+ cmd += ['--exclude_on_edges' ]
622+ print (cmd )
625623 try :
626- subprocess .run (cmd . split () , text = True )
624+ subprocess .run (cmd , text = True )
627625 cellpose_output = numpy .load (os .path .join (temp_img_dir , unique_name + "_seg.npy" ), allow_pickle = True ).item ()
628626
629627 y_data = cellpose_output ["masks" ]
0 commit comments