import ClearMap.IO.IO as io if __name__ == "__main__": sample_dir = sys.argv[1].strip().rstrip("/") imaging_request = sys.argv[2].strip().rstrip("/") output_rootpath = sys.argv[3].strip().rstrip("/") request_name, sample_name = sample_dir.split('/')[-2:] project_dir = os.path.join(output_rootpath, request_name, sample_name, imaging_request, "rawdata/resolution_3.6x") diagnostic_plot_dir = os.path.join(project_dir, "diagnostic_plots") savedir = os.path.join(diagnostic_plot_dir, "merged_cells") os.makedirs(savedir, exist_ok=True) ws = wsp.Workspace('CellMap', directory=project_dir) ws.debug = False im_source = ws.source('stitched') cells_source = ws.source('cells', postfix='raw') """ First plot: the histograms of coordinates, size, intensity """ plt.figure(1) plt.clf() names = cells_source.dtype.names nx, ny = 2, 3 for i, name in enumerate(names): plt.subplot(nx, ny, i + 1) plt.hist(cells_source[name]) plt.title(name) if name in ['source', 'background']: plt.xlabel('counts')
if __name__ == '__main__': n_cores = os.cpu_count() sample_dir = sys.argv[1].strip().rstrip("/") blocks_per_job = int(sys.argv[2]) output_rootpath = sys.argv[3].strip().rstrip("/") array_id = int(os.environ["SLURM_ARRAY_TASK_ID"]) request_name, sample_name = sample_dir.split('/')[-2:] dst_dir = os.path.join(output_rootpath, request_name, sample_name, 'imaging_request_1/rawdata/resolution_3.6x') # Initialize ClearMap2 workspace object ws = wsp.Workspace('CellMap', directory=dst_dir) ws.debug = False print() ws.info() # Load ClearMap2 cell detection parameters fname = '/jukebox/witten/Chris/data/clearmap2/utilities/cell_detection_parameter.p' with open(fname, 'rb') as f: cell_detection_parameter = pickle.load(f) # print('path : ' + fname) cell_detection_parameter['verbose'] = True # Get the blocks blocks = bp.split_into_blocks(ws.source('stitched'), processes='serial', axes=[2],
workspace_dir = os.path.join(output_rootpath, request_name, sample_name, imaging_request, "rawdata/resolution_3.6x") # Set paths to Elastix transformation files and downsized files elastix_inverse_dir = os.path.join(workspace_dir, 'elastix_inverse_transform') ch488_downsized_dir = os.path.join(workspace_dir, 'Ex_488_Em_0_downsized') ch642_downsized_dir = os.path.join(workspace_dir, 'Ex_642_Em_2_downsized') ch488_downsized_file = os.path.join(ch488_downsized_dir, 'downsized_for_atlas_ch488.tif') ch642_downsized_file = os.path.join(ch642_downsized_dir, 'downsized_for_atlas_ch642.tif') # Initialize ClearMap2 workspace object ws = wsp.Workspace('CellMap', directory=workspace_dir) ws.debug = False print() ws.info() # Load detected cells from cells_raw.npy raw_source = ws.source('cells', postfix='raw') size_intensity = np.hstack( [raw_source[c][:, None] for c in ['size', 'background']]) coordinates_raw = np.hstack([raw_source[c][:, None] for c in 'xyz']) # Swap axes to go from horizontal to sagittal orientation coordinates_raw_swapped_axes = np.zeros_like(coordinates_raw) coordinates_raw_swapped_axes[:, 0] = coordinates_raw[:, 2] coordinates_raw_swapped_axes[:, 1] = coordinates_raw[:, 1] coordinates_raw_swapped_axes[:, 2] = coordinates_raw[:, 0]