Commit 01307ffc authored by Chris Evenhuis's avatar Chris Evenhuis
Browse files

Initial commit

parents
This diff is collapsed.
Area,Mean,Mode,X,Y,Perim.,BX,BY,Width,Height,Major,Minor,Angle,Circ.,AR,Round,Solidity,cell
20,255,255,46.400,64.200,18.142,44,61,5,7,6.687,3.808,73.002,0.764,1.756,0.570,0.784,1
66,255,255,65.803,23.333,30.042,60,19,11,9,10.926,7.691,154.351,0.919,1.421,0.704,0.874,2
589,255,255,24.188,46.638,106.225,7,31,33,32,38.092,19.687,42.696,0.656,1.935,0.517,0.879,2
127,255,255,84.059,100.854,50.527,75,94,18,13,19.987,8.090,34.094,0.625,2.470,0.405,0.867,2
816,255,255,82.501,75.407,163.823,63,43,35,61,61.641,16.855,72.893,0.382,3.657,0.273,0.670,3
398,255,255,58.882,49.407,119.983,40,29,32,33,33.352,15.194,38.726,0.347,2.195,0.456,0.578,4
128,255,255,73.211,69.750,42.627,67,63,12,14,14.510,11.232,71.824,0.885,1.292,0.774,0.905,4
252,255,255,37.492,22.687,65.255,26,15,23,19,19.755,16.242,174.987,0.744,1.216,0.822,0.847,5
35,255,255,58.786,30.329,21.556,55,27,7,7,7.385,6.034,130.996,0.947,1.224,0.817,0.875,5
190,255,255,72.026,44.395,67.012,64,31,14,27,25.786,9.382,107.203,0.532,2.749,0.364,0.793,5
37,255,255,16.311,48.500,24.142,13,44,6,9,9.264,5.085,111.622,0.798,1.822,0.549,0.851,5
279,255,255,21.253,45.654,127.296,12,17,20,47,31.961,11.115,90.129,0.216,2.876,0.348,0.447,6
56,255,255,58.393,32.554,51.456,53,23,9,22,20.487,3.480,112.321,0.266,5.886,0.170,0.626,6
25,255,255,37.420,64.140,25.799,33,59,8,9,10.843,2.936,51.813,0.472,3.693,0.271,0.725,6
435,255,255,26.645,33.638,101.054,12,18,27,33,30.608,18.095,66.362,0.535,1.692,0.591,0.730,7
225,255,255,33.264,25.553,70.184,20,18,29,14,29.076,9.853,164.141,0.574,2.951,0.339,0.867,8
713,255,255,54.811,55.479,182.894,34,41,44,38,40.232,22.564,24.995,0.268,1.783,0.561,0.606,11
596,255,255,58.653,53.579,151.238,32,33,48,48,54.797,13.848,134.182,0.327,3.957,0.253,0.641,12
596,255,255,69.629,56.732,171.338,39,41,50,35,40.934,18.539,153.320,0.255,2.208,0.453,0.569,13
50,255,255,12.920,61.620,29.556,10,55,6,12,11.794,5.398,90.383,0.719,2.185,0.458,0.855,13
116,255,255,98.621,80.483,39.456,92,75,13,12,14.294,10.333,138.672,0.936,1.383,0.723,0.924,13
636,255,255,42.627,56.355,113.640,32,34,25,45,38.517,21.024,97.803,0.619,1.832,0.546,0.853,14
140,255,255,34.750,32.079,70.426,26,21,16,27,28.274,6.304,64.549,0.355,4.485,0.223,0.662,15
279,255,255,57.056,46.134,93.497,39,32,28,25,28.972,12.261,50.682,0.401,2.363,0.423,0.667,15
821,255,255,59.629,58.247,162.652,36,42,53,34,41.335,25.290,6.122,0.390,1.634,0.612,0.679,16
57,255,255,18.149,35.149,45.799,14,24,6,20,19.374,3.746,82.847,0.341,5.172,0.193,0.699,17
604,255,255,49.583,56.778,224.693,36,31,37,53,33.964,22.643,84.471,0.150,1.500,0.667,0.453,18
434,255,255,93.071,42.719,160.995,62,30,63,37,58.739,9.407,153.386,0.210,6.244,0.160,0.549,19
63,255,255,42.897,35.325,30.385,37,32,12,7,11.830,6.781,18.270,0.858,1.745,0.573,0.913,19
68,255,255,30.147,78.647,30.627,25,74,10,10,10.840,7.987,146.408,0.911,1.357,0.737,0.895,19
53,255,255,23.349,104.877,34.042,19,99,9,13,13.575,4.971,115.480,0.575,2.731,0.366,0.779,19
738,255,255,51.932,123.573,168.652,30,99,56,42,53.623,17.523,144.940,0.326,3.060,0.327,0.644,19
417,255,255,53.344,40.054,122.912,22,33,53,15,47.966,11.069,3.710,0.347,4.333,0.231,0.741,21
72,255,255,61.931,56.597,33.799,55,53,13,8,13.229,6.930,171.171,0.792,1.909,0.524,0.873,21
275,255,255,28.995,50.551,72.083,15,42,24,20,24.466,14.312,146.658,0.665,1.709,0.585,0.858,22
48,255,255,74.458,53.229,39.456,72,44,5,16,15.159,4.032,89.758,0.387,3.760,0.266,0.727,22
118,255,255,59.034,54.339,46.284,51,49,17,12,17.158,8.757,28.447,0.692,1.959,0.510,0.843,22
34,255,255,68.353,69.235,29.213,65,63,7,11,10.787,4.013,69.421,0.501,2.688,0.372,0.701,22
Area,Mean,Cluster
19.650,5015.609,0
64.816,7482.604,1
66.330,7929.968,2
42.207,7889.641,3
38.143,7393.616,4
28.487,8985.354,5
36.203,10472.895,6
16.159,5644.049,4
0.315,5449.217,4
1.162,5397.394,4
57.309,8922.654,7
49.204,10193.781,8
62.472,9179.455,9
52.252,8112.991,10
33.160,8713.942,11
66.966,8034.936,12
4.484,5963.760,13
49.866,9164.539,14
104.536,9233.992,15
2.381,6028.442,13
40.724,8633.886,16
38.269,8479.494,17
Area,Mean,Mode,X,Y,Perim.,BX,BY,Width,Height,Major,Minor,Angle,Circ.,AR,Round,Solidity,cell
231,255,255,21.950,20.180,68.426,12,11,20,21,24.856,11.833,45.750,0.620,2.101,0.476,0.872,1
160,255,255,37.844,67.744,65.012,24,60,23,14,19.865,10.255,10.503,0.476,1.937,0.516,0.751,1
54,255,255,32.667,14.370,27.799,28,10,9,9,10.200,6.741,132.958,0.878,1.513,0.661,0.864,2
128,255,255,28.641,29.430,41.698,22,23,14,13,13.207,12.340,159.131,0.925,1.070,0.934,0.911,2
254,255,255,28.539,33.894,95.397,19,20,19,31,28.263,11.443,69.660,0.351,2.470,0.405,0.660,4
192,255,255,40.531,67.062,59.598,32,58,18,18,21.652,11.290,139.861,0.679,1.918,0.521,0.844,4
308,255,255,30.237,35.958,94.811,21,17,18,35,28.626,13.699,79.201,0.431,2.090,0.479,0.744,5
51,255,255,3.441,74.069,42.385,0,67,7,12,10.952,5.929,76.127,0.357,1.847,0.541,0.703,5
23,255,255,113.152,1.804,17.899,110,0,7,4,6.825,4.290,6.084,0.902,1.591,0.629,0.920,6
46,255,255,66.478,30.152,23.556,63,26,7,8,8.311,7.047,58.332,1.000,1.179,0.848,0.920,6
662,255,255,73.502,72.921,133.782,56,51,37,39,44.672,18.868,46.565,0.465,2.368,0.422,0.773,6
299,255,255,40.470,47.159,63.355,31,37,20,19,19.857,19.172,21.881,0.936,1.036,0.966,0.946,7
440,255,255,44.486,23.784,95.882,31,12,28,26,28.049,19.973,44.034,0.601,1.404,0.712,0.826,8
54,255,255,23.370,24.611,36.284,17,20,13,11,15.784,4.356,38.541,0.515,3.624,0.276,0.777,8
171,255,255,18.746,59.944,64.669,11,48,15,22,19.609,11.103,117.560,0.514,1.766,0.566,0.784,8
82,255,255,42.780,38.463,53.698,30,34,21,10,15.139,6.897,177.228,0.357,2.195,0.456,0.590,9
308,255,255,59.315,52.032,70.184,49,39,19,24,22.838,17.171,68.255,0.786,1.330,0.752,0.890,9
392,255,255,30.033,77.630,76.083,19,65,22,25,24.961,19.996,76.485,0.851,1.248,0.801,0.919,10
402,255,255,67.965,51.316,82.083,54,41,25,23,24.665,20.752,157.598,0.750,1.189,0.841,0.901,11
75,255,255,58.460,84.300,45.941,51,77,15,13,18.656,5.119,34.292,0.447,3.645,0.274,0.701,11
409,255,255,59.928,36.630,80.326,48,22,23,28,28.253,18.432,61.510,0.797,1.533,0.652,0.914,12
259,255,255,33.782,20.844,60.184,24,12,20,18,19.092,17.273,7.292,0.899,1.105,0.905,0.918,13
751,255,255,92.681,74.677,132.610,72,50,36,46,49.599,19.279,55.606,0.537,2.573,0.389,0.830,14
Area,Mean,Cluster
29.801,10108.765,0
13.888,9176.174,0
2.203,6571.635,1
34.437,7614.156,2
27.924,7557.855,2
53.730,7933.916,2
21.579,8340.960,2
49.035,11167.323,3
27.871,11600.379,3
32.166,10224.539,4
38.764,11045.961,4
30.989,10429.847,5
18.094,9076.155,5
56.726,9853.288,5
from __future__ import print_function, division
from ij import IJ, ImagePlus, WindowManager, ImageStack,CompositeImage
from ij.plugin.frame import RoiManager
from ij.gui import Overlay, Line
from inra.ijpb.measure import RegionAdjacencyGraph
from inra.ijpb.label import LabelImages
import copy
from ij.plugin import Colors
from java.awt import Color
import random
imp=IJ.getImage()
roim = RoiManager.getRoiManager()
roim.reset()
if( True ):
# load the regions into the Roi manager
ip=imp.getProcessor()
from ij.plugin.filter import ThresholdToSelection
for i in range(1,int(ip.getMax())+1):
ip.setThreshold(i,i,0)
roi = ThresholdToSelection().convert( ip )
if( roi is not None):
ip.setRoi(roi)
stats = ip.getStats()
roim.addRoi(roi)
ncell = roim.getCount()
print(ncell)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def get_adj_matrix( imp ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ip=imp.getProcessor()
labels=LabelImages.findAllLabels(imp)
lab2i = dict([ (il,i) for i,il in enumerate(labels) ])
ncell = len(labels)-1
print("Here")
A_dict=dict( [ (i, set()) for i in range(len(labels)) ] )
print(A_dict)
adj=RegionAdjacencyGraph.computeAdjacencies(imp.getProcessor())
for kv in adj:
l1 = lab2i[int(kv.label1)]
l2 = lab2i[int(kv.label2)]
A_dict[l1].add(l2)
A_dict[l2].add(l1)
return A_dict
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def extract_clusters( imp ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
''' calculate the clustering for labelling image, such as one produced
by morpholib watershedding.
This is an image with
background pixels = 0
roi[i] = i
This program returns clusters of touching rois
clusters = list of sets. 0-nclust
sets contains the rois in the cluster
'''
labels =LabelImages.findAllLabels(imp)
# create an diction of sets to sote the adjacency matrix
A_dict = get_adj_matrix( imp )
print(A_dict)
# now grow the clusters
clusters=[]
unassigned=set(range(len(labels)))
while( len(unassigned)>0 ):
clust=set([unassigned.pop()])
n0 = 0
while( len(clust)>n0 ):
n0=len(clust)
for n in list(clust):
clust = clust.union(A_dict[n])
clusters.append(clust)
unassigned = unassigned.difference(clust)
cluster_member={}
cluster_member=[0]*len(labels)
for i,c in enumerate(clusters):
#print(i,cluster_member[i])
for j in c:
cluster_member[j]=i
#for i,c in enumerate(clusters):
#for j in c:
# cluster_member[j]=i
return clusters, cluster_member
ncell = int(imp.getProcessor().getMax())
A_dict = get_adj_matrix( imp )
clusters, cluster_member = extract_clusters(imp)
#cluster_member=[0]*ncell
#for i,c in enumerate(clusters):
# print(i,cluster_member[i])
# for j in c:
# cluster_member[j]=i
print(cluster_member)
labels=LabelImages.findAllLabels(imp)
print(labels)
centers = dict()
for i,l in enumerate(labels):
roi = roim.getRoi(i)
if( roi is not None ):
stats=roi.getStatistics()
centers[i]=[stats.xCentroid,stats.yCentroid]
colors = [ Color.GREEN, Color.RED, Color.BLUE,Color.YELLOW,Color.MAGENTA]
ov = Overlay()
for k,c in enumerate(clusters):
#col = colors[ random.randint(0,len(colors)-1) ]
print("cluster",c)
for n0 in c:
print(" ",n0)
print(" ",A_dict[n0])
for n1 in A_dict[n0]:
print(n0,n1)
line = Line( centers[n0][0], centers[n0][1],centers[n1][0],centers[n1][1])
line.setStrokeColor(Color.RED)
ov.add(line)
imp.setOverlay(ov)
imp.setOverlay(ov)
imp.show()
#for n1 in A_dict[n]:
from __future__ import print_function
from ij import IJ, ImagePlus, WindowManager,Prefs
from ij.gui import Overlay,OvalRoi
from java.awt import Color
from ij.plugin.frame import RoiManager
import os,time
import math
# open a 100X image
# open the Roi file
# select the ones in the stack
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def get_percentile( hist, per):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
for i in range(1,len(hist)):
hist[i] = hist[i]+hist[i-1]
y = ( i for i,v in enumerate(hist) if per*hist[-1]<v )
return next(y)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def translate_roi( roi, dx, dy ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
roi_t = roi.clone()
fp = roi_t.getInterpolatedPolygon(2,False)
fp.xpoints = [ x+dx for x in fp.xpoints]
fp.ypoints = [ y+dy for y in fp.ypoints]
roi_t = PolygonRoi( fp, roi.getType() )
roi_t.setPosition(0,roi.getPosition(),0)
return roi_t
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def check_files_exist( nlist ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print(nlist)
dir_n = nlist[0]
for name in nlist[1:]:
exists = os.path.isfile(os.path.join(dir_n,name))
if( not exists ):
IJ.showMessage("File not found {}".format(name))
RaiseException
print( "All files found")
return
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def select_file():
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''
Prompt user to select a file
returns the
[stack,map,roi]
error if not found
'''
import os
from ij.io import OpenDialog
od= OpenDialog("Select a file")
dirn = od.getDirectory()
name = od.getFileName()
[base,ext] = os.path.splitext(name)
print(base)
if( base[-4:] =='_map' ):
base = base[:-4]
# check is all files are present
rnames = [base+ext for ext in ['.nd2','_map.nd2','.zip'] ]
rnames.insert(0,dirn)
check_files_exist(rnames)
return rnames
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def load_rois( rname, path=None ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
'''Loads rois from a zip file'''
roim = RoiManager().getInstance()
if( roim is None ):
roim = RoiMangager()
else:
roim.reset()
if( path is None ):
IJ.open(roi_n)
else:
IJ.open(os.path.join(path,roi_n))
return
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def convert_cluster_roi(roi, maxtol=200):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
''' Splits up a compound ROI into cells using marker based watersheed with
heights : Euclidean Distance Map
seed : MaxFinder
'''
from ij.plugin.filter import EDM
from ij.plugin.filter import MaximumFinder
from inra.ijpb.watershed import MarkerControlledWatershedTransform2D
from inra.ijpb.binary import BinaryImages
from inra.ijpb.label import LabelImages
from ij.process import ImageProcessor
ip_mask = roi.getMask()
#ImagePlus("mask",ip_mask).show()
ip_valley = EDM().make16bitEDM( ip_mask)
#ImagePlus("valley",ip_valley).show()
MF = MaximumFinder()
ip_seed = MF.findMaxima(ip_valley,maxtol, MF.IN_TOLERANCE, False)
ip_seed = BinaryImages.componentsLabeling( ip_seed, 8, 32 )
ip_valley.invert()
MCWT=MarkerControlledWatershedTransform2D( ip_valley, ip_seed, ip_mask)
ipw = MCWT.applyWithPriorityQueueAndDams()
#ImagePlus("seed",ip_seed).show()
#ImagePlus("seg",ipw).show()
from ij.plugin.filter import ThresholdToSelection
labels = LabelImages.findAllLabels(ipw)
# colors to label the cells with
col_list=[ getattr(Color,col) for col in ['RED','BLUE','GREEN','ORANGE'] ]
ncol = len(col_list)
roim_t = RoiManager(True)
for i in labels:
ipw.setThreshold(i,i,ImageProcessor.NO_LUT_UPDATE)
roi = ThresholdToSelection().convert( ipw )
col = col_list[i%ncol]
roi.setStrokeColor(col)
roim_t.addRoi(roi)
return roim_t
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def ridge_detection_for_string(ip):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rm = RoiManager().getInstance()
if( rm is not None ):
rmb = rm.clone()
rm.reset()
imp2 = ImagePlus( "ridge", ip)
ridge_opt1="line_width=3 high_contrast=80 low_contrast=150 "
ridge_opt2="minimum_line_length=10 maximum=20000 correct_position "
ridge_opt3="estimate_width extend_line add_to_manager method_for_overlap_resolution=NONE"
#'''sigma=1.37 lower_threshold=5.61 upper_threshold=10.88 '''
ridge_opt="{} {}".format(ridge_opt1,ridge_opt2)
IJ.run(imp2,"Ridge Detection",ridge_opt1+ridge_opt2+ridge_opt3)
return rm
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def analyse_gfp(imp, roim, ch=2):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
from ij.plugin.filter import RankFilters,GaussianBlur
from inra.ijpb.morphology import Morphology, Strel
from ij.measure import Measurements, ResultsTable
from ij.gui import Roi,PolygonRoi
from java.lang import Double
from ij.process import ImageProcessor,FloatProcessor,ByteProcessor
from ij.plugin.filter import ParticleAnalyzer
from java.awt import Color
imp.setC(ch)
#ip = imp.getProcessor().duplicate()
cell_rois = roim.getRoisAsArray()
#rti = ResultsTable(True)
#rti.reset()
ov = Overlay()
for ic,roi in enumerate(cell_rois):
print(ic)
[ichan,islice,iframe] =[ roi.getCPosition(),roi.getZPosition(),roi.getTPosition()]
imp.setPosition(ch,islice,iframe)
ip = imp.getProcessor().duplicate()
#roi = roim.getRoi(i)
ip.setRoi(roi)
#imp.setRoi(roi)
mask = ip.getMask()
# mask.dilate()
#ImagePlus("F",mask).show()
#ipt=ip.duplicate()
ipt = ip.crop()
# create the local roi
x0 = roi.getBounds().x
y0 = roi.getBounds().y
roi_t = roi.clone()
fp = roi_t.getInterpolatedPolygon(2,False)
fp.xpoints = [ x- x0 for x in fp.xpoints]
fp.ypoints = [ y- y0 for y in fp.ypoints]
roi_t = PolygonRoi( fp, Roi.POLYGON )
if( True ):
# do a low pass filter to get large scale details
ip_lo = ipt.duplicate()
RankFilters().rank(ip_lo,40,RankFilters.MEDIAN)
#ImagePlus("D",ip_lo).show()
# do a high pass filter to get fine detail
ip_hi = ipt.duplicate()
#ip_hi.setRoi(roi_t)
#RankFilters().rank(ip_hi,4,RankFilters.MEDIAN)
GaussianBlur().blur(ip_hi,3)
#ImagePlus("G",ip_hi).show()
pix_lo = ip_lo.getPixels()
pix_hi = ip_hi.getPixels()
# take the difference
width,height = ip_lo.getWidth(), ip_lo.getHeight()
pix_diff = [0.]*len(pix_hi)
for i in range(len(pix_hi)):
pix_diff[i] = pix_hi[i]-pix_lo[i]
dp = FloatProcessor(width,height,pix_diff)
bp=dp.convertToShortProcessor(True)
bp.setRoi(roi_t)
# get the top 5% of the pixels
hist= bp.getHistogram()
#thresh_50 = get_percentile( hist, 0.50)
#thresh_75 = get_percentile( hist, 0.75)
#print("Tresh 50 ",thresh_50)
#print("Tresh 75", thresh_75)
#bp.setRoi(roi_t)
#bp.setThreshold(thresh_50+0*(thresh_75-thresh_50),2**16-1,ImageProcessor.BLACK_AND_WHITE_LUT )
# Find the strings
bbp = ByteProcessor(bp,True)
rms = ridge_detection_for_string(bbp)
rms.translate(x0,y0)
for roi in rms.getRoisAsArray():
roi.setStrokeColor(Color.RED)
roi.setPosition( 0,islice,iframe)
ov.add(roi)
#ImagePlus("F",bbp).show()
if(True):
ImagePlus("Tmp",ipt).show()
sdfjk
strel = Strel.Shape.DISK.fromRadius(5)
ip3 = Morphology.whiteTopHat( ipt, strel)
#RankFilters().rank(ip3,2,RankFilters.MEDIAN)
#ImagePlus("dsf",ip3).show()
# threshold
ip3.setAutoThreshold('Otsu', True, ip.NO_LUT_UPDATE)
#ip.setThreshold(0,1,ImageProcessor.BLACK_AND_WHITE_LUT )
imp_d = ImagePlus("water",ip3)
IJ.run(imp_d,"Convert to Mask","")
ip3 = imp_d.getProcessor()
ip3.setValue(0)
ip3.fill(mask)
#ImagePlus("sdfjk",ip3).show()
#sdfjk
# for roi in roi_int.getRoisAsArray():
# roi.setStrokeColor(Color.MAGENTA)
# ov.add(roi)
# headings=rt.getHeadings()
# i1 = rt.getCounter()
# for ir in range(i1):
# i0 = rti.getCounter()
## for heading in headings:
# val =rt.getValue(heading, ir)
# rti.setValue(heading, i0, val)
# rti.setValue("cell", i0, ic+1)
# #rti.incrementCounter()
imp.setOverlay(ov)
sdf
# save the info
rti.show("Cell internals - GFP")
filepath=get_filepath(imp)
fileroot=os.path.splitext(filepath)[0]
rti.save( "{}_GFP-int.csv".format(fileroot))
imp.setOverlay(ov)
imp.killRoi()
roi_int.reset()
return
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def ridge_detection_for_string(imp):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
rm = RoiManager().getInstance()
if( rm is not None ):
rois_orig=rm.getRoisAsArray()
rm.reset()
from ij.process import ImageConverter
impt= imp.duplicate()
ic = ImageConverter(impt)
ic.convertToGray8()
#impt.show()
ridge_opt1="line_width=3 low_contrast=160 high_contrast=200 "
ridge_opt2="minimum_line_length=20 maximum=20000 correct_position stack "
ridge_opt3="estimate_width extend_line add_to_manager method_for_overlap_resolution=SLOPE"
#'sigma=1.37 lower_threshold=5.61 upper_threshold=10.88 '
ridge_opt="{} {}".format(ridge_opt1,ridge_opt2)
IJ.run(impt,"Ridge Detection",ridge_opt1+ridge_opt2+ridge_opt3)
impt.setOverlay(None)
rois = [ roi for roi in rm.getRoisAsArray() if roi.getName()[:3]!="JP" ]
rm.reset()
for roi in rois_orig:
roi.setPosition(roi.getCPosition(),roi.getZPosition(), roi.getTPosition() )
rm.addRoi(roi)
return rois
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def analyse_gfp_roi(imp_i, roi, ch=2):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
from ij.plugin.filter import RankFilters,GaussianBlur
from inra.ijpb.morphology import Morphology, Strel
from ij.plugin import Duplicator
[ichan,islice,iframe] =[ roi.getCPosition(),roi.getZPosition(),roi.getTPosition()]
[width, height, nChannels, nSlices, nFrames ] = imp_i.getDimensions()
imp_i.setRoi(roi)
imp = Duplicator().run(imp_i.duplicate(), ch,ch, 1,nSlices, iframe,iframe)
imp.setPosition(1,islice,1)
ip = imp.getProcessor().duplicate()
ip.setRoi(roi)
#ip.crop()
# create the local roi
x0 = roi.getBounds().x
y0 = roi.getBounds().y
roi_t = translate_roi( roi, -x0, -y0 )
mask = roi.getMask()
mask.invert()