Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/imcflibs/imagej/bioformats.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,7 @@
if series_count > 1 and not str(image).endswith(".vsi"):
series_names.append(ome_meta.getImageName(series))
else:
series_names.append(str(image))

series_names.append(os.path.basename(str(image)))

Check warning on line 572 in src/imcflibs/imagej/bioformats.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/bioformats.py#L572

Added line #L572 was not covered by tests
current_position_x = getattr(
ome_meta.getPlanePositionX(series, 0), "value", lambda: 0
)()
Expand Down
44 changes: 35 additions & 9 deletions src/imcflibs/imagej/resultstable.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,50 @@
results_table.show("Results")


def add_results_to_resultstable(results_table, column, values):
"""Add values to the ResultsTable starting from row 0 of a given column.
def add_results_to_resultstable(results_table, column, values, rows=None):

Check warning on line 24 in src/imcflibs/imagej/resultstable.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/resultstable.py#L24

Added line #L24 was not covered by tests
"""Add values to the ResultsTable in a specified column.

This function can work in two ways:
1. If rows=None: adds values sequentially starting from row 0.
2. If rows is provided: adds values to specific row indices.

Parameters
----------
results_table : ij.measure.ResultsTable
a reference of the IJ-ResultsTable
column : string
the column in which to add the values
values : list(int, double or float)
array with values to be added
A reference to the IJ-ResultsTable
column : str
The column in which to add the values.
values : list of int, float or str
Values to be added.
rows : list of int, optional
Specific row indices where values should be added. If None, values are
added sequentially starting from row 0.

Examples
--------
# Add the same value (42) to a given ResultsTable to specific rows (1, 3, 5)
add_results_to_resultstable(rt, "Intensity", 42, rows=[1, 3, 5])
"""
for index, value in enumerate(values):
results_table.setValue(column, index, value)
if not isinstance(values, list) and rows is not None:
values = [values] * len(rows)

Check warning on line 49 in src/imcflibs/imagej/resultstable.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/resultstable.py#L48-L49

Added lines #L48 - L49 were not covered by tests

# Case 1: Add values sequentially from row 0
if rows is None:
for index, value in enumerate(values):
results_table.setValue(column, index, value)

Check warning on line 54 in src/imcflibs/imagej/resultstable.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/resultstable.py#L52-L54

Added lines #L52 - L54 were not covered by tests

# Case 2: Add values to specific rows
else:
if len(values) != len(rows):
raise ValueError(f"Length mismatch: values ({len(values)}) and rows ({len(rows)})")

Check warning on line 59 in src/imcflibs/imagej/resultstable.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/resultstable.py#L58-L59

Added lines #L58 - L59 were not covered by tests

for i, row_index in enumerate(rows):
results_table.setValue(column, row_index, values[i])

Check warning on line 62 in src/imcflibs/imagej/resultstable.py

View check run for this annotation

Codecov / codecov/patch

src/imcflibs/imagej/resultstable.py#L61-L62

Added lines #L61 - L62 were not covered by tests

results_table.show("Results")



def get_resultstable():
"""Instantiate or get the ResultsTable instance.

Expand Down
Loading