예제 #1
0
            centroidDiffMaskedOutDir = dm.makeOutDir(jellyOutDir,
                                                     'centroidDiffMask')
            centroidDiffThresholdedOutDir = dm.makeOutDir(
                jellyOutDir, 'centroidDiffThresholded')
            centroidDiffMaskedHistogramOutDir = dm.makeOutDir(
                jellyOutDir, 'centroidDiffMaskHistogram')

            centroidDiff = im.getGrayscaleImageDiff_absolute(
                troughImg, relaxedImg)
            binaryCentroidDiff = im.getBinaryJelly(centroidDiff,
                                                   lower_bound=0.05,
                                                   upper_bound=1)

            maskedImg = im.applyMask2Img(binaryCentroidDiff, relaxedImg)

            jellyRegion = im.findJellyRegionWithGray(binaryCentroidDiff,
                                                     maskedImg)
            maxIntensity = jellyRegion.max_intensity
            minIntensity = jellyRegion.min_intensity
            print(maxIntensity)
            print(minIntensity)

            # thresholded image off of centroid image jelly mask intensities
            thresholdedGrayImg = im.getBinaryJelly(relaxedImg,
                                                   lower_bound=minIntensity,
                                                   upper_bound=maxIntensity)

            # saving jelly plots
            im.saveJellyPlot(
                centroidDiff,
                str(centroidDiffGrayOutDir /
                    'centroidDiffGray {} - {}.jpg'.format(
예제 #2
0
        grayscaleInfile = dm.getFileFromFrameNum(relaxedFrameNum, stack)

        binaryImg = im.getJellyBinaryImageFromFile(binaryInfile)
        grayImg = im.getJellyGrayImageFromFile(grayscaleInfile)

        print(binaryImg.shape)
        print(binaryImg)

        plt.imshow(binaryImg)
        plt.show()

        print(grayImg)

        maskedImg = im.applyMask2Img(binaryImg, grayImg)

        jellyRegion = im.findJellyRegionWithGray(binaryImg, grayImg)
        maxIntensity = jellyRegion.max_intensity
        minIntensity = jellyRegion.min_intensity
        print(maxIntensity)
        print(minIntensity)

        thresholdedGrayImg = im.getBinaryJelly(grayImg,
                                               lower_bound=minIntensity,
                                               upper_bound=maxIntensity)

        print(maskedImg)

        plt.hist(maskedImg.ravel())
        plt.show()
        #
        im.saveJellyPlot(
예제 #3
0
def selectAverageTroughBinaryArea(fileSubset, thresholdingDir, recordingName, peaksOnBinaryImage, peak2InflectionDiff, peak2TroughDiff):
    maxIntensities = []
    minIntensities = []
    for i, peak in enumerate(peaksOnBinaryImage):
        if peak + peak2InflectionDiff >= 0 and peak + peak2TroughDiff < len(fileSubset):
            troughInfile = fileSubset[peak + peak2TroughDiff]
            relaxedInfile = fileSubset[peak + peak2InflectionDiff]
            troughImg = im.getJellyGrayImageFromFile(troughInfile)
            relaxedImg = im.getJellyGrayImageFromFile(relaxedInfile)

            centroidDiff = im.getGrayscaleImageDiff_absolute(troughImg, relaxedImg)
            binaryCentroidDiff = im.getBinaryJelly(centroidDiff, lower_bound=0.05)
            maskedImg = im.applyMask2Img(binaryCentroidDiff, relaxedImg)
            jellyRegion = im.findJellyRegionWithGray(binaryCentroidDiff, maskedImg)
            maxIntensity = jellyRegion.max_intensity
            minIntensity = jellyRegion.min_intensity
            maxIntensities.append(maxIntensity)
            minIntensities.append(minIntensity)

    indensityDifference = np.mean(maxIntensities) - np.mean(minIntensities)

    lowerThreshold = np.mean(minIntensities) + (0.1 * indensityDifference)

    print('peak2TroughDiff: {}'.format(peak2TroughDiff))

    while True:

        troughAreas = []

        for peak in peaksOnBinaryImage:
            peakInfile = fileSubset[peak]
            troughInfile = fileSubset[peak+peak2TroughDiff]

            peakImg = im.getJellyGrayImageFromFile(peakInfile)
            troughImg = im.getJellyGrayImageFromFile(troughInfile)

            binaryPeakImg = im.getBinaryJelly(peakImg, lowerThreshold)
            binaryTroughImg = im.getBinaryJelly(troughImg, lowerThreshold)

            im.saveJellyPlot(im.juxtaposeImages(np.array([[binaryPeakImg, binaryTroughImg]])),
                             (thresholdingDir / '{}_thresholdVerification_{}.png'.format(recordingName, peak)))

            jellyTroughBinaryArea = im.findBinaryArea(binaryTroughImg)

            troughAreas.append(jellyTroughBinaryArea)

        if CHIME: dm.chime(MAC, 'input time')
        print('average trough area: {}, sd of trough areas: {}'.format(np.mean(troughAreas), np.std(troughAreas)))

        print('Change thresholds: ')
        print('select \'1\' to change {} which is {}'.format('lowerThreshold', lowerThreshold))
        print('select \'2\' to remove a peak from peaksOnBinaryImage')
        print('or \'3\' to continue.')

        selectionVar = dm.getSelection([1, 2, 3])
        if selectionVar == '1':
            lowerThreshold = dm.reassignFloatVariable(lowerThreshold, 'lowerThreshold')
            dm.replaceDir(thresholdingDir)
        elif selectionVar == '2':
            print('peaksOnBinaryImage: {}'.format(peaksOnBinaryImage))
            index2Pop = int(dm.getSelection(list(range(len(peaksOnBinaryImage)))))
            peaksOnBinaryImage.pop(index2Pop)
        else:
            return np.mean(troughAreas)