Ejemplo n.º 1
0
    def compute_initial_figure(self):
        ax = self.axes[0]
        IMAGE_CACHE = util.ImageCache()

        img = [IMAGE_CACHE.getVolume(fp) for fp in self.fullState.filePaths]
        img0 = img[self.windowIndex - 1][0, ...]
        img1 = img[self.windowIndex][0, ...]

        img0 = gaussian(img0, .5)
        img1 = gaussian(img1, .5)

        img0 = self._simpleNorm(img0, 1.1)
        img1 = self._simpleNorm(img1, 1.1)

        p0Stack = img0.max(axis=0)**1.2
        p1Stack = img1.max(axis=0)**1.2
        p1Stack = skimgTransform.rotate(p1Stack, angle=0.85)

        shift = np.array(
            phase_cross_correlation(p0Stack,
                                    p1Stack,
                                    upsample_factor=1,
                                    return_error=False))

        dY, dX = int(round(shift[0])), int(round(shift[1]))
        sliceY1, sliceY2 = self.buildSlices(dY, p1Stack.shape[0])
        sliceX1, sliceX2 = self.buildSlices(dX, p1Stack.shape[1])
        shifted = np.zeros(p1Stack.shape)
        shifted[sliceY1, sliceX1] = p1Stack[sliceY2, sliceX2]
        p1Stack = shifted

        mergedStack = p0Stack
        mergedStack = np.zeros((p0Stack.shape[0], p0Stack.shape[1], 3))
        mergedStack[:, :, 0] = p0Stack
        mergedStack[:, :, 1] = p1Stack
        mergedStack[:, :, 2] = np.minimum(p0Stack, p1Stack)

        ax.get_xaxis().set_visible(False)
        ax.get_yaxis().set_visible(False)
        ax.set_aspect('equal')
        ax.imshow(mergedStack)
Ejemplo n.º 2
0
import pandas as pd

import os
import sys

import pydynamo_brain.files as files
import pydynamo_brain.util as util

from pydynamo_brain.analysis import allTrees, allBranches, addedSubtractedTransitioned, allPuncta
from pydynamo_brain.analysis.neurom import neuroMAnalysisForNeurons
from pydynamo_brain.analysis.functions.tree import *
from pydynamo_brain.analysis.functions.branch import *
from pydynamo_brain.analysis.functions.puncta import *
from pydynamo_brain.model import FiloType

_IMG_CACHE = util.ImageCache()


# Either use a provided path, or open a filepicker to select one.
def usePathOrPick(path):
    if path is not None:
        return path
    app = QtWidgets.QApplication([])
    filePath, _ = QtWidgets.QFileDialog.getOpenFileName(
        None, "Open dynamo save file", "", "Dynamo files (*.dyn.gz)")
    return str(filePath)


# Example of running tree-based analysis
def runTreeAnalysis(path=None):
    # List of analysis functions to produce answers across each tree: