Пример #1
0
filesRaw = glob.glob(Raw_path)

# In[6]:

for fname in filesRaw:
    if os.path.exists(fname) == True:
        if os.path.exists(basedirResults2Dextended + '_' +
                          os.path.basename(fname)) == False:
            print(basedirResults2Dextended + '_' + os.path.basename(fname))
            print(fname)
            y = imread(fname)
            restored = RestorationModel.predict(y, axes, n_tiles=(1, 4, 4))
            #restored = RestorationModel.predict(y, axes, n_tiles = (1,4,8)) #n_tiles is for the decomposition of the image in (z,y,x). (1,2,2) will work with light images. Less tiles we have, faster the calculation is
            projection = ProjectionModel.predict(restored,
                                                 axes,
                                                 n_tiles=(1, 1, 2))
            #projection = ProjectionModel.predict(restored, axes, n_tiles = (1,1,2)) #n_tiles is for the decomposition of the image in (z,y,x). There is overlapping in the decomposition wich is managed by the program itself
            axes_restored = axes.replace(ProjectionModel.proj_params.axis, '')
            #restored = restored.astype('uint8') # if prediction and projection running at the same time
            #restored = restored.astype('uint16') # if projection training set creation or waiting for a future projection
            projection = projection.astype('uint8')
            #save_tiff_imagej_compatible((basedirResults3Dextended  + os.path.basename(fname)) , restored, axes)
            save_tiff_imagej_compatible(
                (basedirResults2Dextended + '_' + os.path.basename(fname)),
                projection, axes_restored)

# In[]:

from csbdeep.utils import Path
Пример #2
0
# In[6]:

for fname in filesRaw:
    if os.path.exists(fname) == True:
        if os.path.exists(basedirResults3Dextended +
                          os.path.basename(fname)) == False or os.path.exists(
                              basedirResults2Dextended + '_' +
                              os.path.basename(fname)) == False:
            print(fname)
            y = imread(fname)
            restored = RestorationModel.predict(
                y, axes, n_tiles=(1, 2, 4)
            )  #n_tiles is for the decomposition of the image in (z,y,x). (1,2,2) will work with light images. Less tiles we have, faster the calculation is
            projection = ProjectionModel.predict(
                restored, axes, n_tiles=(1, 1, 1)
            )  #n_tiles is for the decomposition of the image in (z,y,x). There is overlapping in the decomposition wich is managed by the program itself
            axes_restored = axes.replace(ProjectionModel.proj_params.axis, '')
            #restored = restored.astype('uint8') # if prediction and projection running at the same time
            restored = restored.astype(
                'uint16'
            )  # if projection training set creation or waiting for a future projection
            projection = projection.astype('uint8')
            save_tiff_imagej_compatible(
                (basedirResults3Dextended + os.path.basename(fname)), restored,
                axes)
            save_tiff_imagej_compatible(
                (basedirResults2Dextended + '_' + os.path.basename(fname)),
                projection, axes_restored)

# In[]:
Пример #3
0
from csbdeep.utils import Path, download_and_extract_zip_file, plot_some
from csbdeep.io import save_tiff_imagej_compatible
from csbdeep.models import ProjectionCARE

# In[2]:

basedirLow = '/local/u934/private/v_kapoor/ProjectionTraining/MasterLow/NotsoLow/'
basedirResults = '/local/u934/private/v_kapoor/ProjectionTraining/MasterLow/NetworkProjections'
ModelName = 'DrosophilaDenoisingProjection'
BaseDir = '/local/u934/private/v_kapoor/CurieDeepLearningModels/'

# In[3]:

model = ProjectionCARE(config=None, name=ModelName, basedir=BaseDir)

# In[4]:

Raw_path = os.path.join(basedirLow, '*tif')
Path(basedirResults).mkdir(exist_ok=True)
axes = 'ZYX'
filesRaw = glob.glob(Raw_path)
filesRaw.sort
for fname in filesRaw:
    x = imread(fname)
    print('Saving file' + basedirResults + '%s_' + os.path.basename(fname))
    restored = model.predict(x, axes, n_tiles=(1, 4, 4))
    axes_restored = axes.replace(model.proj_params.axis, '')
    save_tiff_imagej_compatible(
        (basedirResults + '%s_' + os.path.basename(fname)) % model.name,
        restored, axes_restored)