Skip to content

Commit 30b428f

Browse files
committed
Merge branch 'code-sebastien-20230418' into devel
2 parents c16348c + f09aa12 commit 30b428f

3 files changed

Lines changed: 35 additions & 24 deletions

File tree

src/imcflibs/imagej/labelimage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def label_image_to_roi_list(label_image, low_thresh=None):
2020
2121
Returns
2222
-------
23-
roi_list : list(roi) FIXME: what's the exact "roi" type?
23+
roi_list : list(ij.gui.Roi)
2424
List of all the ROIs converted from the label image
2525
"""
2626

src/imcflibs/imagej/misc.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import time
55

66
from ij import IJ # pylint: disable-msg=import-error
7-
from ij.measure import ResultsTable # pylint: disable-msg=import-error
8-
from ij.plugin.frame import RoiManager # pylint: disable-msg=import-error
97

8+
from . import prefs
109
from ..log import LOG as log
1110

1211

@@ -198,30 +197,24 @@ def get_free_memory():
198197
return free_memory
199198

200199

201-
def setup_clean_ij_environment(rm=None, rt=None):
200+
def setup_clean_ij_environment(rm=None, rt=None): # pylint: disable-msg=unused-argument
202201
"""Set up a clean and defined ImageJ environment.
203202
203+
Clean active results table, roi manager and log, close any open image.
204+
205+
"Fresh Start" is described here: https://imagej.nih.gov/ij/notes.html following this suggestion: https://forum.image.sc/t/fresh-start-macro-command-in-imagej-fiji/43102
206+
204207
Parameters
205208
----------
206209
rm : RoiManager, optional
207-
A reference to an IJ-RoiManager instance.
210+
Will be ignored (kept for keeping API compatibility).
208211
rt : ResultsTable, optional
209-
A reference to an IJ-ResultsTable instance.
212+
Will be ignored (kept for keeping API compatibility).
210213
"""
211-
# FIXME: use function(s) from the "roimanager" module!
212-
if not rm:
213-
rm = RoiManager.getInstance()
214-
if not rm:
215-
rm = RoiManager()
216-
217-
if not rt:
218-
rt = ResultsTable.getInstance()
219-
if not rt:
220-
rt = ResultsTable()
221-
222-
rm.runCommand("reset")
223-
rt.reset()
224-
IJ.log(r"\\Clear")
225-
226-
# FIXME: integrate commands from method below
227-
# fix_ij_options()
214+
215+
IJ.run("Fresh Start", "")
216+
IJ.log("\\Clear")
217+
218+
prefs.fix_ij_options()
219+
220+
return

src/imcflibs/imagej/prefs.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Functions to work with ImageJ preferences."""
22

3-
from ij import Prefs # pylint: disable-msg=E0401
3+
from ij import Prefs, IJ # pylint: disable-msg=E0401
44

55

66
def debug_mode():
@@ -18,3 +18,21 @@ def debug_mode():
1818
"""
1919
debug = Prefs.get("imcf.debugging", "false")
2020
return debug == "true"
21+
22+
23+
def fix_ij_options():
24+
"""Wrapper to setup ImageJ default options."""
25+
26+
# disable inverting LUT
27+
IJ.run("Appearance...", " menu=0 16-bit=Automatic")
28+
# set foreground color to be white, background black
29+
IJ.run("Colors...", "foreground=white background=black selection=red")
30+
# black BG for binary images and pad edges when eroding
31+
IJ.run("Options...", "black pad")
32+
# set saving format to .txt files
33+
IJ.run("Input/Output...", "file=.txt save_column save_row")
34+
# ============= DON'T MOVE UPWARDS =============
35+
# set "Black Background" in "Binary Options"
36+
IJ.run("Options...", "black")
37+
# scale when converting = checked
38+
IJ.run("Conversions...", "scale")

0 commit comments

Comments
 (0)