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
a70b76b6
Commit
a70b76b6
authored
1 month ago
by
Laurent Guerard
Browse files
Options
Downloads
Patches
Plain Diff
Fix resizing threshold and add log
parent
aa9f80b0
Branches
fix-path-handling
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
+25
-6
25 additions, 6 deletions
1_identify_fibers.py
with
25 additions
and
6 deletions
1_identify_fibers.py
+
25
−
6
View file @
a70b76b6
...
...
@@ -47,7 +47,7 @@ import sys
# python imports
import
time
from
ch.epfl.biop.ij2command
import
Labels2
Composite
Rois
from
ch.epfl.biop.ij2command
import
Labels2Rois
# TrackMate imports
from
fiji.plugin.trackmate
import
Logger
,
Model
,
Settings
,
TrackMate
...
...
@@ -743,21 +743,25 @@ if __name__ == "__main__":
# image (pre)processing and segmentation (-> ROIs)# imp, firstC, lastC, firstZ,
# lastZ, firstT, lastT
misc
.
timed_log
(
"
Getting the membrane channel
"
)
membrane
=
Duplicator
().
run
(
raw
,
membrane_channel
,
membrane_channel
,
1
,
1
,
1
,
1
)
if
(
membrane
.
getWidth
()
*
membrane
.
getHeight
())
>
100000
:
while
(
membrane
.
getWidth
()
*
membrane
.
getHeight
())
>
100000
000
:
misc
.
timed_log
(
"
Image is too large, resizing to speed up processing
"
)
membrane
=
membrane
.
resize
(
membrane
.
getWidth
()
/
2
,
membrane
.
getHeight
()
/
2
,
"
none
"
,
)
misc
.
timed_log
(
"
Pre processing the image for segmentation
"
)
imp_bgd_corrected
=
do_background_correction
(
membrane
)
IJ
.
run
(
"
Conversions...
"
,
"
scale
"
)
IJ
.
run
(
imp_bgd_corrected
,
"
16-bit
"
,
""
)
misc
.
timed_log
(
"
Running the segmentation
"
)
imp_result
=
run_tm
(
imp_bgd_corrected
,
1
,
...
...
@@ -769,25 +773,31 @@ if __name__ == "__main__":
perimeter_thresh
=
[
minPer
,
maxPer
],
)
misc
.
timed_log
(
"
Resizing the segmentation results (if needed)
"
)
imp_result
=
imp_result
.
resize
(
raw
.
getWidth
(),
raw
.
getHeight
(),
"
none
"
,
)
misc
.
timed_log
(
"
Saving the segmentation results
"
)
IJ
.
saveAs
(
imp_result
,
"
Tiff
"
,
os
.
path
.
join
(
output_dir
,
raw_image_title
+
"
_
"
+
str
(
serie_index
)
+
"
_all_fibers_
binary
"
,
raw_image_title
+
"
_
"
+
str
(
serie_index
)
+
"
_all_fibers_
labels
"
,
),
)
command
.
run
(
Labels2CompositeRois
,
True
,
"
rm
"
,
rm
,
"
imp
"
,
imp_result
).
get
()
misc
.
timed_log
(
"
Getting the ROIs
"
)
command
.
run
(
Labels2Rois
,
True
,
"
rm
"
,
rm
,
"
imp
"
,
imp_result
).
get
()
misc
.
timed_log
(
"
Enlarging and renumbering the ROIs
"
)
enlarge_all_rois
(
enlarge_radius
,
rm
,
raw_image_calibration
.
pixelWidth
)
renumber_rois
(
rm
)
misc
.
timed_log
(
"
Saving the ROIs
"
)
save_all_rois
(
rm
,
os
.
path
.
join
(
...
...
@@ -798,11 +808,12 @@ if __name__ == "__main__":
# check for positive fibers
if
fiber_channel
>
0
:
misc
.
timed_log
(
"
Checking for positive fibers
"
)
if
min_fiber_intensity
==
0
:
min_fiber_intensity
=
get_threshold_from_method
(
raw
,
fiber_channel
,
"
Mean
"
)[
0
]
IJ
.
log
(
"
automatic intensity threshold detection: True
"
)
misc
.
timed_
log
(
"
automatic intensity threshold detection: True
"
)
IJ
.
log
(
"
fiber intensity threshold:
"
+
str
(
min_fiber_intensity
))
change_all_roi_color
(
rm
,
"
blue
"
)
...
...
@@ -810,6 +821,7 @@ if __name__ == "__main__":
raw
,
fiber_channel
,
rm
,
min_fiber_intensity
)
change_subset_roi_color
(
rm
,
positive_fibers
,
"
magenta
"
)
misc
.
timed_log
(
"
Saving positive fibers
"
)
save_selected_rois
(
rm
,
positive_fibers
,
...
...
@@ -823,6 +835,7 @@ if __name__ == "__main__":
)
# measure size & shape, save
misc
.
timed_log
(
"
Measuring the ROIs
"
)
IJ
.
run
(
"
Set Measurements...
"
,
"
area perimeter shape feret
'
s redirect=None decimal=4
"
,
...
...
@@ -841,6 +854,7 @@ if __name__ == "__main__":
add_results
(
rt
,
"
MHC Positive Fibers (magenta)
"
,
positive_fibers
,
"
YES
"
)
# print(rt.size())
misc
.
timed_log
(
"
Saving the measurements
"
)
rt
.
save
(
os
.
path
.
join
(
output_dir
,
...
...
@@ -851,7 +865,11 @@ if __name__ == "__main__":
)
)
# print("saved the all_fibers_results.csv")
# dress up the original image, save a overlay-png, present original to the user
# dress up the original image, save a overlay-png, present original
# to the user
misc
.
timed_log
(
"
Improve the contrast and show the results to save an overlay image
"
)
rm
.
show
()
raw
.
show
()
show_all_rois_on_image
(
rm
,
raw
)
...
...
@@ -877,6 +895,7 @@ if __name__ == "__main__":
raw
.
setDisplayMode
(
IJ
.
GRAYSCALE
)
show_all_rois_on_image
(
rm
,
raw
)
misc
.
timed_log
(
"
Save log
"
)
IJ
.
selectWindow
(
"
Log
"
)
IJ
.
saveAs
(
"
Text
"
,
...
...
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