コード例 #1
0
    #######DO NOT NEED TO TOUCH BELOW
    makedir(out)
    #load src, concatenate and make sure appropriate bitdepth
    vol = np.asarray([
        tifffile.imread(xx).astype('uint8') for xx in listdirfull(src)
    ])  #need to do the uint8 thing
    nsrc = src + '.tif'
    if resize_scale:
        vol = resize(
            vol,
            [xx * resize_scale for xx in tifffile.imread(atlas_path).shape])
    tifffile.imsave(nsrc, vol.astype('uint16'))  #needs to be 16 bit!

    #now run elastix:
    elastix_command_line_call(fx=atlas_path,
                              mv=nsrc,
                              out=out,
                              parameters=parameters)

if False:
    #elastix parameter file to use for alignment typically both Order1_Par0000affine.txt follwed by Order2_Par0000bspline.txt
    parameters = [
        '/media/tpisano/FAT32/volumetric/elastix_bsplineopt/Order2_Par0000bspline.txt'
    ]

    #Path to Atlas, note that this must be oriented in the same way as your dataset, see FIJI/ImageJ for ways to reorient
    atlas_path = '/media/tpisano/FAT32/volumetric/average_template_25_coronal.tif'

    #location of aligned files from serial_section_processing.py
    src = '/media/tpisano/FAT32/volumetric/elastix_bsplineopt/affine.tif'

    #location to save elastix output into
コード例 #2
0
cell = str(sys.argv[4]) #folder for cell channel e.g. Ex_642_Em_2
param_fld = "/jukebox/wang/zahra/python/BrainPipe/parameterfolder" #change if using rat
#registration vol to atlas
# cell = True #no separate cell/registration volume
# src = "/jukebox/LightSheetTransfer/tp/20200701_12_55_28_20170207_db_bl6_crii_rpv_01/"

if stepid == 0:
    reg = os.path.join(src, reg)
    mv = os.path.join(reg, "downsized_for_atlas.tif")
    fx = "/jukebox/LightSheetTransfer/atlas/sagittal_atlas_20um_iso.tif"
    out = os.path.join(os.path.dirname(src), "elastix")
    if not os.path.exists(out): os.mkdir(out)
    
    params = [os.path.join(param_fld, xx) for xx in os.listdir(param_fld)]
    #run
    e_out, transformfiles = elastix_command_line_call(fx, mv, out, params)

    if cell:
        #cell vol to registration vol
        mv = os.path.join(src, cell+"/downsized_for_atlas.tif")
        fx = os.path.join(src, reg+"/downsized_for_atlas.tif")
        
        out = os.path.join(src, "elastix/%s_to_%s" % (cell, reg))
        if not os.path.exists(out): os.mkdir(out)
        
        params = [os.path.join(param_fld, xx) for xx in os.listdir(param_fld)]
        #run
        e_out, transformfiles = elastix_command_line_call(fx, mv, out, params)
elif stepid == 1:
    #atlas to registration vol
    #inverse transform
コード例 #3
0
        print("Doing inverse transform atlas -> reg")
        #atlas to registration vol
        #inverse transform
        fx1 = os.path.join(src, "Ex_488_Em_0_downsized",
                           "downsized_for_atlas_ch488.tif")
        mv1 = atl
        assert os.path.exists(fx1)
        assert os.path.exists(mv1)
        print("\nPath to downsized vol for inverse registration to atlas: %s" %
              fx1)
        print("\nPath to atlas: %s" % mv1)

        params = [os.path.join(param_fld, xx) for xx in os.listdir(param_fld)]
        #run
        e_out, transformfiles = elastix_command_line_call(
            fx1, mv1, out1, params)

    elif array_id == 1:
        #registration vol to cell vol
        #inverse transform
        print("Doing inverse transform reg -> cell")

        mv2 = os.path.join(src, "Ex_488_Em_0_downsized",
                           "downsized_for_atlas_ch488.tif")
        fx2 = os.path.join(src, "Ex_642_Em_2_downsized",
                           "downsized_for_atlas_ch642.tif")

        assert os.path.exists(fx2)
        assert os.path.exists(mv2)

        out2 = os.path.join(out1, "488_to_642")