Skip to content

Commit d955723

Browse files
authored
Merge pull request #7 from gletort/bigfish_nan
add tophat as a parameter
2 parents ca9b93b + 80dc5a9 commit d955723

4 files changed

Lines changed: 19 additions & 9 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "fishfeats"
7-
version = "1.4.4"
7+
version = "1.4.5"
88
description = "Napari plugin for RNA-Fish+cells analysis pipeline"
99
license.file = "LICENSE"
1010
readme = "README.md"

src/fish_feats/MainImage.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -772,25 +772,25 @@ def get_rna_threshold(self, rnachan):
772772
return self.rnas[rnachan].threshold
773773
return 0
774774

775-
def find_rna(self, rnachan, spotZRadius, spotXYRadius, rmExtremeZ, threshold=None):
775+
def find_rna(self, rnachan, spotZRadius, spotXYRadius, rmExtremeZ, threshold=None, tophat_radius=0 ):
776776
if self.rnas.get(rnachan) is None:
777777
rnaspot = RNASpots(rnachan, verbose=self.verbose)
778778
self.rnas[rnachan] = rnaspot
779779
else:
780780
rnaspot = self.rnas[rnachan]
781781
rnaspot.reset_spots()
782782
rnaimg = self.image[rnachan,:,:,:]
783-
rnaspot.detect_spots_withbigfish(rnaimg, scaleZ=self.scaleZ, scaleXY=self.scaleXY, spotZRadius=spotZRadius, spotXYRadius=spotXYRadius, rmextr=rmExtremeZ, threshold=threshold)
783+
rnaspot.detect_spots_withbigfish(rnaimg, scaleZ=self.scaleZ, scaleXY=self.scaleXY, spotZRadius=spotZRadius, spotXYRadius=spotXYRadius, rmextr=rmExtremeZ, threshold=threshold, tophat_radius=tophat_radius )
784784

785-
def find_rnas_in_image(self, rnaimg, chanlist, spotZRadius, spotXYRadius, threshold=None):
785+
def find_rnas_in_image(self, rnaimg, chanlist, spotZRadius, spotXYRadius, threshold=None, tophat_radius=0):
786786
chanlist = str(chanlist)
787787
if self.rnas.get(chanlist) is None:
788788
rnaspot = RNASpots(chanlist, verbose=self.verbose)
789789
self.rnas[chanlist] = rnaspot
790790
else:
791791
rnaspot = self.rnas[chanlist]
792792
rnaspot.reset_spots()
793-
rnaspot.detect_spots_withbigfish(rnaimg, scaleZ=self.scaleZ, scaleXY=self.scaleXY, spotZRadius=spotZRadius, spotXYRadius=spotXYRadius, rmextr=False, threshold=threshold)
793+
rnaspot.detect_spots_withbigfish(rnaimg, scaleZ=self.scaleZ, scaleXY=self.scaleXY, spotZRadius=spotZRadius, spotXYRadius=spotXYRadius, rmextr=False, threshold=threshold, tophat_radius=tophat_radius)
794794
return rnaspot.get_points()
795795

796796
def find_blobs_in_image(self, rnaimg, chanlist, minSigma, threshold):

src/fish_feats/NapaRNA.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def load_RNA_parameters(self, channel, paras):
5050
""" default or loaded RNA parameters """
5151
paras["RNA"+str(channel)+"_spotZRadiusNm"] = 1000
5252
paras["RNA"+str(channel)+"_spotXYRadiusNm"] = 250
53+
paras["RNA"+str(channel)+"_tophatRadius"] = 20
5354
paras["RNA"+str(channel)+"_removeSpotInExtremeZ"] = True
5455
#paras["RNA"+str(channel)+"_drawing_spot_size"] = 3
5556
paras["RNA"+str(channel)+"_threshold"] = self.mig.get_rna_threshold(channel)
@@ -171,6 +172,11 @@ def __init__( self, napari_viewer, parameters, nchan, mig, cfg, defmethod, rnafi
171172
threshold_line.addWidget(self.automatic_threshold)
172173

173174
bigfish_layout.addLayout(threshold_line)
175+
176+
## top-hat radius
177+
tophat_line, self.tophat_radius = fwid.value_line( "TopHat radius (pixels)", 20, descr="Preprocessing with top-hat. Put 0 to disable" )
178+
self.tophat_radius.setText( str(self.paras["RNA"+str(self.rnachannel)+"_tophatRadius"]) )
179+
bigfish_layout.addLayout( tophat_line )
174180

175181
self.remove_extrem = QCheckBox("Remove spots in extremes Z")
176182
self.remove_extrem.setChecked(False)
@@ -215,6 +221,7 @@ def go_rna(self):
215221
self.cfg.addParameter("RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_method", self.method.currentText())
216222
self.cfg.addParameter( "RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_spotZRadiusNm", int(self.spotz_radius.text()) )
217223
self.cfg.addParameter( "RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_spotXYRadiusNm", int(self.spotxy_radius.text()) )
224+
self.cfg.addParameter( "RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_tophatRadius", int(self.tophat_radius.text()) )
218225
self.cfg.addParameter( "RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_threshold", float(self.threshold.text()) )
219226
self.cfg.addParameter( "RNA"+str(self.rnachannel), "RNA"+str(self.rnachannel)+"_removeSpotInExtremeZ", self.remove_extrem.isChecked() )
220227
#cfg.addParameter( "RNA"+str(rna_channel), "RNA"+str(rna_channel)+"_drawing_spot_size", drawing_spot_size )
@@ -274,6 +281,7 @@ def channel_choice(self):
274281
self.filename.setText(rnafilename)
275282
self.spotz_radius.setText(str(self.paras["RNA"+str(self.rnachannel)+"_spotZRadiusNm"]))
276283
self.spotxy_radius.setText(str(self.paras["RNA"+str(self.rnachannel)+"_spotXYRadiusNm"]))
284+
self.tophat_radius.setText(str(self.paras["RNA"+str(self.rnachannel)+"_tophatRadius"]))
277285
self.threshold.setText(str(self.paras["RNA"+str(self.rnachannel)+"_threshold"]))
278286
self.automatic_threshold.setChecked( self.paras["RNA"+str(self.rnachannel)+"_automatic_threshold"] )
279287
self.remove_extrem.setChecked( self.paras["RNA"+str(self.rnachannel)+"_removeSpotInExtremeZ"] )
@@ -291,9 +299,10 @@ def load_segmentationfile_rna(self ):
291299
self.end_segmented_rna()
292300

293301
def segment_rna(self, threshold):
302+
""" Launch the segmentation with selected parameters """
294303
chanel = self.rnachannel
295304
start_time = time.time()
296-
self.mig.find_rna( self.rnachannel, int(self.spotz_radius.text()), int(self.spotxy_radius.text()), self.remove_extrem.isChecked(), threshold )
305+
self.mig.find_rna( self.rnachannel, int(self.spotz_radius.text()), int(self.spotxy_radius.text()), self.remove_extrem.isChecked(), threshold, int(self.tophat_radius.text()) )
297306
print("RNA big-fish segmentation finished in {:.3f}".format((time.time()-start_time)/60)+" min")
298307
self.end_segmented_rna()
299308

src/fish_feats/RNASpots.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ def nspots(self):
5050
return len(self.spots)
5151
return 0
5252

53-
def detect_spots_withbigfish(self, img, scaleZ, scaleXY, spotZRadius, spotXYRadius, rmextr=True, threshold=None):
53+
def detect_spots_withbigfish(self, img, scaleZ, scaleXY, spotZRadius, spotXYRadius, rmextr=True, threshold=None, tophat_radius=0):
5454
""" Detect RNA spots with big-fish """
55-
from fish_feats.Separe import topHat
5655
from fish_feats.SegmentObj import normalizeQuantile
57-
img = topHat(img, xyrad=floor(30*scaleXY))
56+
if tophat_radius > 0:
57+
from fish_feats.Separe import topHat
58+
img = topHat( img, xyrad=floor(tophat_radius) )
5859
img = normalizeQuantile(img, qmin=0.001, qmax=0.999, vmax=255)
5960
# detect with big-Fish: spots sizes are to be put in nanometers
6061
spots, self.threshold = detection.detect_spots(

0 commit comments

Comments
 (0)