def main(): parser = argparse.ArgumentParser( description='Run preprocess on in data folder') parser.add_argument('--in-folder', type=str, help='Folder of input data', required=True) parser.add_argument('--out-folder', type=str, help='Output location for preprocessed images', required=True) parser.add_argument( '--average-img', type=str, help='Use this average image to impute the missing voxels in targets') parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) average_img_obj = ScanWrapper(args.average_img) preprocess_obj = PreprocessAverageImputation(in_folder_obj, out_folder_obj, average_img_obj, args.num_process) preprocess_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) # parser.add_argument( # '--in-mask', # type=str, # default=None, # help='If is none, the orignal input images will be used' # ) parser.add_argument('--file-list', type=str) parser.add_argument('--out-png-folder', type=str) parser.add_argument('--offset-axial', type=int, default=0) parser.add_argument('--offset-sagittal', type=int, default=0) parser.add_argument('--offset-coronal', type=int, default=0) parser.add_argument('--vmin', type=float, default=-1000) parser.add_argument('--vmax', type=float, default=500) parser.add_argument('--unit-label', type=str, default=None, help='If none, the color bar will be omitted.') parser.add_argument('--num-process', type=str, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list) out_folder_obj = DataFolder(args.out_png_folder, args.file_list) out_folder_obj.change_suffix('') mkdir_p(args.out_png_folder) plot_obj = ParalClipPlot(in_folder_obj, out_folder_obj, args.offset_axial, args.offset_sagittal, args.offset_coronal, args.vmin, args.vmax, args.unit_label, args.num_process) plot_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--in-affine-folder') parser.add_argument('--in-warped-folder', type=str) parser.add_argument('--ref-img', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--out-png-folder', type=str) parser.add_argument('--step-axial', type=int, default=50) parser.add_argument('--step-sagittal', type=int, default=75) parser.add_argument('--step-coronal', type=int, default=30) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_ori_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) in_affine_folder_obj = DataFolder(args.in_affine_folder, args.file_list_txt) in_warped_folder_obj = DataFolder(args.in_warped_folder, args.file_list_txt) out_png_folder_obj = DataFolder(args.out_png_folder, args.file_list_txt) out_png_folder_obj.change_suffix('.png') ref_img = ScanWrapper(args.ref_img) exe_obj = Overlay3Views(in_ori_folder_obj, in_affine_folder_obj, in_warped_folder_obj, out_png_folder_obj, ref_img, args.step_axial, args.step_sagittal, args.step_coronal, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str, default='/nfs/masi/xuk9/SPORE/data/data_flat') parser.add_argument('--in-mask-folder', type=str, default='/nfs/masi/xuk9/src/lungmask/SPORE/lung_mask_nii') parser.add_argument('--out-clip-png-folder', type=str, default='/nfs/masi/xuk9/src/lungmask/SPORE/lung_mask_nii_clip_png') parser.add_argument('--file-list-txt', type=str, default='/nfs/masi/xuk9/SPORE/data/vlsp_data_list.txt') parser.add_argument('--num-process', type=int, default=1) args = parser.parse_args() mkdir_p(args.in_mask_folder) mkdir_p(args.out_clip_png_folder) in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_mask_folder_obj = DataFolder(args.in_mask_folder, args.file_list_txt) out_clip_png_folder_obj = DataFolder(args.out_clip_png_folder, args.file_list_txt) out_clip_png_folder_obj.change_suffix('.png') exe_obj = ParalPPVMask( in_folder_obj, out_mask_folder_obj, out_clip_png_folder_obj, args.num_process ) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--out-mask-folder', type=str) parser.add_argument('--out-label-folder', type=str) parser.add_argument('--out-clip-png-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_mask_folder_obj = DataFolder(args.out_mask_folder, args.file_list_txt) out_label_folder_obj = DataFolder(args.out_label_folder, args.file_list_txt) out_clip_png_folder_obj = DataFolder(args.out_clip_png_folder, args.file_list_txt) out_clip_png_folder_obj.change_suffix('.png') exe_obj = ParalPPVMask( in_folder_obj, out_mask_folder_obj, out_label_folder_obj, out_clip_png_folder_obj, args.num_process ) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--val', type=float) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_ori_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = ParaReplaceNan(in_ori_folder_obj, out_folder_obj, args.val, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--in-effective-mask-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--gt-mask', type=str) parser.add_argument('--out-csv', type=str) parser.add_argument('--num-process', type=int, default=25) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) in_effective_mask_folder_obj = DataFolder(args.in_effective_mask_folder, args.file_list_txt) dice_cal = GetMeanSurfaceDist(in_folder_obj, in_effective_mask_folder_obj, args.num_process, args.gt_mask) dice_cal.get_surface_metric() dice_cal.save_csv(args.out_csv)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-mask-folder1', type=str) parser.add_argument('--in-mask-folder2', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder1_obj = DataFolder(args.in_mask_folder1, args.file_list_txt) in_folder2_obj = DataFolder(args.in_mask_folder2, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = Union2Masks(in_folder1_obj, in_folder2_obj, out_folder_obj, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--in-ref-valid-mask', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--etch-radius', type=int) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) effect_region = GetDiceEffectiveRegion(in_folder_obj, args.in_ref_valid_mask, args.num_process, out_folder_obj, args.etch_radius) effect_region.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-mask-folder', type=str) parser.add_argument('--in-ref-mask', type=str, default=None) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_mask_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) ref_mask_obj = ScanWrapper(args.in_ref_mask) exe_obj = GetDiffMask(in_folder_obj, out_folder_obj, ref_mask_obj, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--inverse-label', action='store_true') parser.add_argument('--out-mask-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_mask_folder_obj = DataFolder(args.out_mask_folder, args.file_list_txt) logger.info(f'Get non-nan mask in folder from {args.in_folder}') exe_obj = NonNanRegionMask(in_folder_obj, out_mask_folder_obj, args.num_process, args.inverse_label) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser(description='Run preprocess on in data folder') parser.add_argument('--in-folder', type=str, help='Folder of input data', required=True) parser.add_argument('--out-folder', type=str, help='Output location for preprocessed images', required=True) parser.add_argument('--c3d-path', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) preprocess_obj = PreprocessTrimROI( in_folder_obj, out_folder_obj, args.c3d_path, args.num_process ) preprocess_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-clip', type=int) parser.add_argument('--vmin', type=float) parser.add_argument('--vmax', type=float) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) out_folder_obj.change_suffix('.png') exe_obj = ParalClipMontagePlotNII(in_folder_obj, out_folder_obj, args.num_clip, args.vmin, args.vmax, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--in-mask-folder', type=str, default=None) parser.add_argument('--in-mask-file', type=str, default=None) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--ambient-val', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) in_mask_folder_obj = None in_mask_file_obj = None if args.in_mask_folder is not None: logger.info(f'Create in_mask_folder_obj with {args.in_mask_folder}') in_mask_folder_obj = DataFolder(args.in_mask_folder, args.file_list_txt) logger.info( f'Apply mask in folder {args.in_mask_folder} to {args.in_folder}') if args.in_mask_file is not None: logger.info(f'Create in_mask_file_obj with {args.in_mask_file}') in_mask_file_obj = ScanWrapper(args.in_mask_file) ambient_val = None ambient_val_str = args.ambient_val if ambient_val_str is 'nan': ambient_val = np.nan else: ambient_val = float(args.ambient_val) exe_obj = ApplyMask(in_folder_obj, out_folder_obj, ambient_val, args.num_process, in_mask_folder_obj=in_mask_folder_obj, in_mask_file_obj=in_mask_file_obj) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-jac-det-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--out-csv', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_jac_det_folder, args.file_list_txt) dice_cal = JacobianDetStatics(in_folder_obj, args.num_process) dice_cal.get_jac_statics() dice_cal.save_csv(args.out_csv)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--in-ref-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--niftyreg-path', type=str, default=reg_resample_path) parser.add_argument('--int-order', type=int, default=3) parser.add_argument('--pad-val', type=str, default='NaN') parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_ori_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) in_ref_folder_obj = DataFolder(args.in_ref_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = ParalResampleNiftyReg(in_ori_folder_obj, in_ref_folder_obj, out_folder_obj, args.niftyreg_path, args.int_order, args.num_process, args.pad_val) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--c3d-path', type=str) parser.add_argument('--command-str', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_ori_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = ParalC3DCommand( in_ori_folder_obj, out_folder_obj, args.c3d_path, args.command_str, args.num_process ) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--out-average-path', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) exe_obj = AverageValidRegion(in_folder_obj, args.num_process) exe_obj.run_get_average() exe_obj.output_result_average(args.out_average_path, ambient_val=np.nan)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--in-omat-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--out-corrected-folder') parser.add_argument('--file-list-txt', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) in_omat_obj = DataFolder(args.in_omat_folder, args.file_list_txt) in_omat_obj.change_suffix('.txt') out_corrected_folder_obj = DataFolder(args.out_corrected_folder, args.file_list_txt) exe_obj = AverageValidRegion(in_folder_obj, in_omat_obj, out_corrected_folder_obj, args.num_process) exe_obj.run_get_average() exe_obj.run_get_variance() exe_obj.output_result_folder(args.out_folder, np.nan)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--inter', type=int, default=3) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--dim', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() dim_list = args.dim.split('x') logger.info( f'Resample image to dimension {dim_list[0]}x{dim_list[1]}x{dim_list[2]}' ) in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = C3DResample(in_folder_obj, out_folder_obj, dim_list, args.inter, args.num_process) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-ori-folder', type=str) parser.add_argument('--out-folder', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--c3d-path', type=str) parser.add_argument('--res-val', type=float) parser.add_argument('--int-order', type=int, default=3) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_ori_folder_obj = DataFolder(args.in_ori_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) exe_obj = ParalResample( in_ori_folder_obj, out_folder_obj, args.c3d_path, args.res_val, args.int_order, args.num_process ) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--mask-img', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--out-bin-path', type=str) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) mask_img = ScanWrapper(args.mask_img) creator_obj = CreateMaskedFeatureMatrix(in_folder_obj, mask_img) creator_obj.load_data() creator_obj.save_to_bin(args.out_bin_path)
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str, help='Folder of NIFTI files') parser.add_argument('--out-folder', type=str, help='Output folder') parser.add_argument('--file-list-txt', type=str, help='List of filename in plain txt (ls ${in_folder} > file_list)') parser.add_argument('--num-clip', type=int, help='Number of clip on each direction') parser.add_argument('--vmin', type=float, default=-1000) parser.add_argument('--vmax', type=float, default=600) parser.add_argument('--num-process', type=int, default=10, help='Number of cores') args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) out_folder_obj = DataFolder(args.out_folder, args.file_list_txt) out_folder_obj.change_suffix('.png') exe_obj = ParalClipMontagePlotNII( in_folder_obj, out_folder_obj, args.num_clip, args.vmin, args.vmax, args.num_process ) exe_obj.run_parallel()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--in-folder', type=str) parser.add_argument('--ref-img', type=str) parser.add_argument('--file-list-txt', type=str) parser.add_argument('--niftyreg-root', type=str) parser.add_argument('--out-csv', type=str) parser.add_argument('--num-process', type=int, default=10) args = parser.parse_args() in_folder_obj = DataFolder(args.in_folder, args.file_list_txt) ref_img = ScanWrapper(args.ref_img) exe_obj = MetricNMI(in_folder_obj, ref_img, args.niftyreg_root, args.num_process) exe_obj.get_nmi() exe_obj.save_csv(args.out_csv)