Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
myosoft-imcf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
imcf
myosoft-imcf
Commits
c7e1cb93
Commit
c7e1cb93
authored
3 months ago
by
Laurent Guerard
Browse files
Options
Downloads
Patches
Plain Diff
Remove some filtering measurements and change order of input and imports
parent
948a18cc
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
1_identify_fibers.py
+56
-25
56 additions, 25 deletions
1_identify_fibers.py
with
56 additions
and
25 deletions
1_identify_fibers.py
+
56
−
25
View file @
c7e1cb93
# @ String (visibility=MESSAGE, value="<html><b> Welcome to Myosoft - identify fibers! </b></html>") msg1
# @ File (label="Select folder with your images", description="select folder with your images", style="directory") src_dir
# @ String(label="Extension for the images to look for", value="czi") filename_filter
# @ File (label="Select directory for output", style="directory") output_dir
# @ File(label="Cellpose environment folder", style="directory", description="Folder with the cellpose env") cellpose_dir
# @ Boolean (label="close image after processing", description="tick this box when using batch mode", value=False) close_raw
# @ String (visibility=MESSAGE, value="<html><b> Morphometric Gates </b></html>") msg2
# @ Integer (label="Min Area [um²]", value=10) minAr
# @ Integer (label="Max Area [um²]", value=6000) maxAr
# @ Double (label="Min Circularity", value=0.5) minCir
# @ Double (label="Max Circularity", value=1) maxCir
# @ Integer (label="Min perimeter [um]", value=5) minPer
# @ Integer (label="Max perimeter [um]", value=300) maxPer
# @ String (visibility=MESSAGE, value="<html><b> Expand ROIS to match fibers </b></html>") msg3
# @ Double (label="ROI expansion [microns]", value=1) enlarge_radius
# @ String (visibility=MESSAGE, value="<html><b> channel positions in the hyperstack </b></html>") msg5
# @ Integer (label="Membrane staining channel number", style="slider", min=1, max=5, value=1) membrane_channel
# @ Integer (label="Fiber staining (MHC) channel number (0=skip)", style="slider", min=0, max=5, value=3) fiber_channel
# @ Integer (label="minimum fiber intensity (0=auto)", description="0 = automatic threshold detection", value=0) min_fiber_intensity
# @ CommandService command
# @ RoiManager rm
# @ ResultsTable rt
# this is a python rewrite of the original ijm published at
# https://github.com/Hyojung-Choo/Myosoft/blob/Myosoft-hub/Scripts/central%20nuclei%20counter.ijm
# ─── Requirements ─────────────────────────────────────────────────────────────
# List of update sites needed for the code
# * TrackMate-Cellpose
# * IMCF
# * PTBIOP
# * CLIJ-CLIJ2
# ─── Imports ──────────────────────────────────────────────────────────────────
# IJ imports
# TODO: are the imports RoiManager and ResultsTable needed when using the services?
from
ij
import
IJ
,
WindowManager
as
wm
from
ij.plugin
import
Duplicator
,
RoiEnlarger
,
RoiScaler
from
ij.measure
import
ResultsTable
import
os
import
sys
# Bio-formats imports
from
loci.plugins
import
BF
from
loci.plugins.in
import
ImporterOptions
# from loci.plugins import BF
# from loci.plugins.in import ImporterOptions
# python imports
import
time
import
os
import
sy
s
from
ch.epfl.biop.ij2command
import
Labels2CompositeRoi
s
# TrackMate imports
from
fiji.plugin.trackmate
import
Logger
,
Model
,
SelectionModel
,
Settings
,
TrackMate
from
fiji.plugin.trackmate
import
Logger
,
Model
,
Settings
,
TrackMate
from
fiji.plugin.trackmate.action
import
LabelImgExporter
from
fiji.plugin.trackmate.cellpose
import
CellposeDetectorFactory
from
fiji.plugin.trackmate.cellpose.CellposeSettings
import
PretrainedModel
...
...
@@ -153,7 +185,7 @@ def get_threshold_from_method(imp, channel, method):
list
the upper and the lower threshold (integer values)
"""
imp
.
setC
(
channel
)
# starts at 1
imp
.
setC
(
channel
)
# starts at 1
ip
=
imp
.
getProcessor
()
ip
.
setAutoThreshold
(
method
+
"
dark
"
)
lower_thr
=
ip
.
getMinThreshold
()
...
...
@@ -266,18 +298,17 @@ def run_tm(
if
any
(
quality_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
QUALITY
"
,
quality_thresh
)
if
any
(
intensity_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
MEAN_INTENSITY_CH
"
+
str
(
channel_seg
),
intensity_thresh
)
settings
=
set_trackmate_filter
(
settings
,
"
MEAN_INTENSITY_CH
"
+
str
(
channel_seg
),
intensity_thresh
)
if
any
(
circularity_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
CIRCULARITY
"
,
circularity_thresh
)
if
any
(
area_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
AREA
"
,
area_thresh
)
if
any
(
perimeter_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
PERIMETER
"
,
perimeter_thresh
)
if
any
(
feret_thresh
):
settings
=
set_trackmate_filter
(
settings
,
"
FERET
"
,
feret_thresh
)
print
(
settings
)
# print(settings)
# Configure tracker
settings
.
trackerFactory
=
SparseLAPTrackerFactory
()
...
...
@@ -674,15 +705,15 @@ measure_in_all_rois( raw, membrane_channel, rm )
rt
=
ResultsTable
.
getResultsTable
(
"
Results
"
)
print
rt
.
size
()
if
fiber_channel
>
0
:
print
rt
.
size
(
)
preset_results_column
(
rt
,
"
MHC Positive Fibers (magenta)
"
,
"
NO
"
)
print
rt
.
size
(
)
add_results
(
rt
,
"
MHC Positive Fibers (magenta)
"
,
positive_fibers
,
"
YES
"
)
print
rt
.
size
(
)
rt
.
save
(
output_dir
+
"
/
"
+
raw_image_title
+
"
_all_fibers_results.csv
"
)
IJ
.
log
(
"
-- settings used --
"
)
IJ
.
log
(
"
area =
"
+
str
(
minAr
)
+
"
-
"
+
str
(
maxAr
))
IJ
.
log
(
"
perimeter =
"
+
str
(
minPer
)
+
"
-
"
+
str
(
maxPer
)
)
IJ
.
log
(
"
circularity =
"
+
str
(
minCir
)
+
"
-
"
+
str
(
maxCir
)
)
IJ
.
log
(
"
ROI expansion [microns] =
"
+
str
(
enlarge_radius
)
)
IJ
.
log
(
"
Membrane channel =
"
+
str
(
membrane_channel
)
)
IJ
.
log
(
"
MHC positive fiber channel =
"
+
str
(
fiber_channel
)
)
# IJ.log("sub-tiling = " + str(tiling_factor))
IJ
.
log
(
"
-- settings used --
"
)
print
"
saved the all_fibers_results.csv
"
# dress up the original image, save a overlay-png, present original to the user
rm
.
show
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment