コード例 #1
0
def run():
    # Ask for a folder containing all the time points, one per folder
    #dc = DirectoryChooser("Choose folder")
    #folder = dc.getDirectory()
    #folder = '/run/user/52828/gvfs/smb-share:server=keller-s7,share=microscopy1/SV3/RC_17-10-31/GCaMP6s_2_20171031_145624.corrected/SPM00'
    #folder = "/home/albert/shares/zlaticlab/Nadine/Raghav/2017-05-10/GCaMP6s_1_20170510_115003.corrected/dff_on_fused/from_Raghav/MVD_Results/"
    folder = "/home/albert/shares/zlaticlab/Nadine/Raghav/2017-05-10/GCaMP6s_1_20170510_115003.corrected/tests/dff_on_4view_fused/from_Raghav/MVD_Results/"
    print folder

    if not folder:
        return

    # Find the list of directories in that folder, and pick
    # one single file inside each, ending in:
    ending = "CM00_CHN00.klb"

    #DEBUGGING
    num_timepoints = 100

    java = Weaver.method(
        """
    static public final void maxer(final KLB klb, final ImgPlus target, final String path) throws java.io.IOException {
      Cursor c1 = target.cursor();
      Cursor c2 = klb.readFull(path).cursor();
      while (c1.hasNext()) {
        c1.next();
        c2.next();
        UnsignedShortType s1 = (UnsignedShortType) c1.get();
        UnsignedShortType s2 = (UnsignedShortType) c2.get();
        s1.set( (short) Math.max( s1.get(), s2.get() ) );
      }
  }
  """, [KLB, ImgPlus, Cursor, UnsignedShortType])

    max_img = None

    klb = KLB.newInstance()

    counter = 0

    for root, dirs, files in os.walk(folder):
        for filename in files:
            if filename.endswith(ending):
                counter += 1
                path = os.path.join(root, filename)
                print counter, path

                # Use the first opened stack as the image stack into which to accumulate max values
                if max_img is None:
                    max_img = klb.readFull(path)
                else:
                    java.maxer(klb, max_img, path)

            num_timepoints -= 1
            if num_timepoints < 0:
                break

    # DONE
    IJF.show(max_img)
コード例 #2
0
class CellLoader(CacheLoader):
    klb = KLB.newInstance()

    def get(self, index):
        img = CellLoader.klb.readFull(timepoint_paths[index]).getImg()
        # Each cell has "1" as its dimension in the last axis (time)
        # and index as its min coordinate in the last axis (time)
        return Cell(
            Intervals.dimensionsAsIntArray(img) + array([1], 'i'),
            Intervals.minAsLongArray(img) + array([index], 'l'),
            extractArrayAccess(img))
コード例 #3
0
 def openImage():
   print rel_path
   if rel_path.endswith(".klb"):
     try:
       klb = KLB.newInstance()
       img = klb.readFull(os.path.join(base_path, rel_path))
       IL.wrap(img, rel_path).show()
     except:
       print sys.exc_info()
   else:
     print "via IJ.open"
     IJ.open(os.path.join(base_path, rel_path))
コード例 #4
0
 def openImage():
     print rel_path
     if rel_path.endswith(".klb"):
         if (KLB == None):
             print "Cannot open KLB due to missing module"
         try:
             klb = KLB.newInstance()
             img = klb.readFull(os.path.join(base_path, rel_path))
             IL.wrap(img, rel_path).show()
         except:
             print sys.exc_info()
     else:
         print "via IJ.open"
         IJ.open(os.path.join(base_path, rel_path))
コード例 #5
0
    "maxTrust": 4,  # for rejecting candidates
}

# Parameters for all to all registration
paramsTileConfiguration = {
    "all_to_all": True,
    "fixed_tile_index": [0],  # tiles that won't move
    "maxAllowedError": 0,  # zero, as recommended by Saalfeld
    "maxPlateauwidth": 200,  # like in TrakEM2
    "maxIterations": 1000,  # like in TrakEM2
    "damp": 1.0,  # default
}

# STOP EDITING HERE

klb = KLB.newInstance()

# paths for same timepoint, 4 different cameras
paths = []
timepointDir = srcDir + "TM000000/"
for camera_index, channel_index in zip(xrange(4), [1, 1, 0, 0]):
    paths.append(timepointDir + "SPM00_TM000000_CM0" + str(camera_index) +
                 "_CHN0" + str(channel_index) + ".klb")

for path in paths:
    print basename(path)

img0 = klb.readFull(paths[0])
img1 = klb.readFull(paths[1])
img2 = klb.readFull(paths[2])
img3 = klb.readFull(paths[3])
コード例 #6
0
 def __init__(self, dimensions, filenames):
     super(Thread, self).__init__()
     self.filenames = filenames
     self.aimg = ArrayImgs.floats(dimensions)
     self.klb = KLB.newInstance()
コード例 #7
0
ファイル: io.py プロジェクト: mwinding/scripts
 def __init__(self):
     self.klb = KLB.newInstance()
コード例 #8
0
ファイル: io.py プロジェクト: mwinding/scripts
    """ Read a file as an ArrayImg of UnsignedShortType """
    ra = RandomAccessFile(path, 'r')
    try:
        if header < 0:
            # Interpret from the end: useful for files with variable header lengths
            # such as some types of uncompressed TIFF formats
            header = ra.length() + header
        ra.skipBytes(header)
        bytes = zeros(reduce(operator.mul, dimensions), 'b')
        ra.read(bytes)
        return ArrayImgs.unsignedBytes(bytes, dimensions)
    finally:
        ra.close()


__klb__ = KLB.newInstance()


def readKLB(path):
    return __klb__.readFull(path)


def writeZip(img, path, title=""):
    if isinstance(img, RandomAccessibleInterval):
        imp = IL.wrap(img, title)
    elif isinstance(img, ImagePlus):
        imp = img
        if title:
            imp.setTitle(title)
    else:
        syncPrint("Cannot writeZip to %s:\n  Unsupported image type %s" %
コード例 #9
0
 def __init__(self, transforms, calibration):
     self.transforms = transforms
     self.klb = KLB.newInstance()