Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 4.2.x branch #7

Merged
merged 74 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
cd60d0a
Improve JSON handling (#89)
DavidStirling Nov 5, 2021
7eb9630
Allow settings upgrades for JSON pipelines (#90)
DavidStirling Nov 12, 2021
1fb05f6
Prevent inclusion of temporary db measurement placeholders.
DavidStirling Feb 4, 2022
1db53a4
Remove duplicated line
DavidStirling Feb 4, 2022
019fa88
fix for NamesAndTypes manual threshold (#93)
callum-jpg Feb 17, 2022
7129835
Allow build with Python 3.9.x (#92)
ximion Feb 17, 2022
ad2aa6b
fix for 3d plane relabelling (#95)
callum-jpg Mar 8, 2022
cb7b151
incomplete fix for #4442
callum-jpg Mar 23, 2022
644aafc
Merge pull request #91 from CellProfiler:exportfeatures
bethac07 Jul 8, 2022
705c21e
remove alpha from gray2rgb
bethac07 Jul 8, 2022
60377e1
fix: enable running headless with the Metadata module (#1) (#94)
ovesh Jul 11, 2022
dc5f5ad
Limit headless extraction to only when needed
bethac07 Jul 11, 2022
d3a905e
Merge pull request #99 from CellProfiler/skimage_19
gnodar01 Jul 15, 2022
4dfb516
Clear up extraction_methods iteration
gnodar01 Jul 15, 2022
597a3ea
Remove unnecessary name de-mangling on self
gnodar01 Jul 15, 2022
e178b0a
Update namesandtypes.py (#96)
rsenft1 Jul 16, 2022
0964446
Channelstack for 4+ channel non-volumetric images
bethac07 Jul 16, 2022
38f4fbd
Replace string literal with constant
gnodar01 Jul 16, 2022
461cb86
Merge pull request #100 from CellProfiler/limit_headless_metadata
gnodar01 Jul 16, 2022
901a070
Replace numpy object check with builtin
gnodar01 Jul 18, 2022
065dd61
Merge pull request #103 from CellProfiler/numpy123support
gnodar01 Jul 18, 2022
b5bd580
Merge pull request #102 from CellProfiler/issues/4495
gnodar01 Jul 18, 2022
76bb86b
Add rest of original changes
bethac07 Jul 21, 2022
c91f1a3
Fix failing tests
bethac07 Jul 21, 2022
92ead08
Add function for pure export of grouping tags
bethac07 Jul 21, 2022
cab425e
Replace depreacted liveness check
gnodar01 Jul 21, 2022
46894ef
Merge pull request #108 from CellProfiler/threading-deprecation
gnodar01 Jul 21, 2022
182a042
Setup CI tests (#104)
gnodar01 Jul 25, 2022
ad3eb57
Add ability to ignore all errors on run (#105)
bethac07 Jul 28, 2022
ee81fe6
Rename old function
bethac07 Jul 28, 2022
ae8ec18
Merge pull request #107 from CellProfiler/issues/4413
gnodar01 Jul 28, 2022
42df351
bump centrosome
bethac07 Jul 28, 2022
e419aa4
Merge branch 'master' into issues/#4442
gnodar01 Jul 29, 2022
a5ccf19
Merge pull request #106 from CellProfiler/issues/#4442
gnodar01 Jul 29, 2022
8ad52f0
Merge pull request #109 from CellProfiler/centrosome_121
gnodar01 Jul 29, 2022
e577a5c
Bump to 4.2.2 (#110)
gnodar01 Jul 29, 2022
4713e30
Add preference for widget inspector
gnodar01 Aug 1, 2022
4a67bf7
Add config write/read for widget inspector
gnodar01 Aug 2, 2022
6a0cdf6
Add global_only flag
gnodar01 Aug 2, 2022
ca6c66b
Merge pull request #111 from CellProfiler/debugger_flag
gnodar01 Aug 2, 2022
0d60df6
Close file if we have to
bethac07 Aug 8, 2022
8da9e1a
don't truncate existing file
bethac07 Aug 8, 2022
5e26e5d
recreate group
bethac07 Aug 8, 2022
ebb7c91
simplify unneeded logic
bethac07 Aug 8, 2022
83360b5
simplify
bethac07 Aug 8, 2022
28fff80
whoops, that was too simple
bethac07 Aug 8, 2022
ee6742a
Make sure w+ handled before file open
gnodar01 Aug 9, 2022
aa61eae
Bump python-bioformats to 4.0.6
bethac07 Aug 9, 2022
8cedc47
Remove w+ support and add x support
gnodar01 Aug 9, 2022
de66577
Remove lingering comment
gnodar01 Aug 9, 2022
5e0bca3
Merge pull request #112 from CellProfiler/issues/4606
gnodar01 Aug 9, 2022
ea068e7
Merge pull request #113 from CellProfiler/pb_406
gnodar01 Aug 9, 2022
ed6b754
Bump version to 4.2.3
gnodar01 Aug 9, 2022
ddf64a0
Merge pull request #114 from CellProfiler/423_bump
gnodar01 Aug 9, 2022
2441e99
v4.2.4rc1
bethac07 Aug 11, 2022
a2fa5c8
v4.2.4
bethac07 Aug 11, 2022
39edcec
Update namesandtypes.py
bethac07 Dec 13, 2022
126c096
split out note by regex rather than pipes
bethac07 Dec 13, 2022
d313299
Remove prints
bethac07 Dec 13, 2022
a2dca0b
Make sure we're grabbing the "]" at the end of the note, not just any…
bethac07 Dec 13, 2022
07443c7
pin skimage due to 4663
bethac07 Dec 13, 2022
00f154c
Add back support for older pipelines
bethac07 Dec 13, 2022
bbbf3a2
Merge pull request #135 from CellProfiler/issues/4666_425
bethac07 Dec 13, 2022
b7fb32b
Merge pull request #137 from CellProfiler/issues/4674_425
bethac07 Dec 14, 2022
fec4c4c
4.2.5, bump python-bioformats
bethac07 Dec 14, 2022
b4ba0eb
Bump centrosome
bethac07 Aug 7, 2023
cf2b198
Merge pull request #148 from CellProfiler/pins_426
bethac07 Aug 7, 2023
89c9580
4.26
bethac07 Aug 7, 2023
078fd11
Merge pull request #149 from CellProfiler/4.2.6
bethac07 Aug 7, 2023
2bb4b80
Merge branch 'compat-4-2' into 4.2.x
DavidStirling Feb 26, 2024
319249e
Merge pull request #1 from CellProfiler/4.2.x
DavidStirling Feb 26, 2024
0aa64ad
Update dependencies
DavidStirling Feb 28, 2024
ec31027
Disable sentry reports
DavidStirling Feb 28, 2024
acd0e70
Disable telemetry prompt
DavidStirling Feb 29, 2024
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
80 changes: 62 additions & 18 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,67 @@
name: run-core-tests
jobs:
build:
runs-on: ubuntu-latest
test:
name: Install and test Core
strategy:
max-parallel: 4
matrix:
python-version: [3.8]
os: [macos-11]
python-version: [ 3.8, 3.9 ]
fail-fast: false
runs-on: ${{ matrix.os }}
if: github.event.pull_request.draft == false
env:
CP_MYSQL_TEST_HOST: "127.0.0.1"
CP_MYSQL_TEST_DB: "cellprofiler_test"
CP_MYSQL_TEST_USER: "root"
CP_MYSQL_TEST_PASSWORD: "None"
steps:
- uses: actions/checkout@v1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Installation
run:
|
python -m pip install --upgrade pip
pip install numpy
pip install -e .[test]
- name: Test
run: pytest
name: cellprofiler-core
on: [push]
- uses: actions/checkout@v2
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
architecture: x64
python-version: ${{ matrix.python-version }}
- name: Get pip cache dir
id: pip-cache-dir
run: |
echo "::set-output name=dir::$(pip cache dir)"
- name: Cache pip
uses: actions/cache@v3
id: cache-pip
with:
path: ${{ steps.pip-cache-dir.outputs.dir }}
key: ${{ runner.os }}-${{ env.pythonLocation }}-${{ hashFiles('**/setup.py') }}
- name: Install java
uses: actions/setup-java@v1
with:
java-version: '14.0.1' # The JDK version to make available on the path.
java-package: jdk
architecture: x64
- name: Mac - Install and setup mysql
if: startsWith(matrix.os, 'macos')
env:
LC_ALL: "en_US.UTF-8"
run: |
brew install mysql
mysql.server start
mysql --host=$CP_MYSQL_TEST_HOST --user=$CP_MYSQL_TEST_USER --execute="CREATE DATABASE $CP_MYSQL_TEST_DB;" --skip-password
- name: Installation
run:
|
pip install pyinstaller
pip install --upgrade pip setuptools wheel
pip install numpy>=1.20.1
# git clone https://github.com/CellProfiler/CellProfiler.git ~/cellprofiler
pip install -e .[test]
# pip install -e ~/cellprofiler
- name: Test
run: pytest -k 'not test_load_objects and not test_load_single_object'
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review, review_requested]
push:
branches:
- 'master'
workflow_dispatch:

2 changes: 1 addition & 1 deletion cellprofiler_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.2.1"
__version__ = "4.2.6"
3 changes: 3 additions & 0 deletions cellprofiler_core/analysis/_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from ..preferences import get_plugin_directory
from ..preferences import get_conserve_memory
from ..preferences import get_temporary_directory
from ..preferences import get_always_continue
from ..preferences import preferences_as_dict
from ..utilities.analysis import close_all_on_exec, start_daemon_thread
from ..utilities.analysis import find_analysis_worker_source
Expand Down Expand Up @@ -664,6 +665,8 @@ def start_workers(cls, num=None):
get_plugin_directory(),
"--conserve-memory",
str(get_conserve_memory()),
"--always-continue",
str(get_always_continue())
]
# stdin for the subprocesses serves as a deadman's switch. When
# closed, the subprocess exits.
Expand Down
2 changes: 2 additions & 0 deletions cellprofiler_core/constants/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
IMAGE = "Image"
EXPERIMENT = "Experiment"
RELATIONSHIP = "Relationship"
DB_TEMP = "ExportToDb"
NEIGHBORS = "Neighbors"
OBJECT = "Object"
disallowed_object_names = [IMAGE, EXPERIMENT, RELATIONSHIP]
Expand Down Expand Up @@ -33,6 +34,7 @@
OBJECT_NUMBER = "ObjectNumber"
GROUP_NUMBER = "Group_Number" # 1-based group index
GROUP_INDEX = "Group_Index" # 1-based index within group
GROUP_LENGTH = "Group_Length"
R_FIRST_IMAGE_NUMBER = IMAGE_NUMBER + "_" + "First"
R_FIRST_OBJECT_NUMBER = OBJECT_NUMBER + "_" + "First"
R_SECOND_IMAGE_NUMBER = IMAGE_NUMBER + "_" + "Second"
Expand Down
1 change: 1 addition & 0 deletions cellprofiler_core/constants/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
IMAGE_NUMBER = "ImageNumber"
GROUP_NUMBER = "Group_Number"
GROUP_INDEX = "Group_Index"
GROUP_LENGTH = "Group_Length"
CURRENT = "Current"
NUMBER_OF_IMAGE_SETS = "NumberOfImageSets"
NUMBER_OF_MODULES = "NumberOfModules"
Expand Down
5 changes: 3 additions & 2 deletions cellprofiler_core/image/abstract_image/file/_file_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ def __set_image(self):
c=self.channel,
series=self.series,
index=self.index,
rescale=self.rescale,
rescale=self.rescale if isinstance(self.rescale, bool) else False,
wants_max_intensity=True,
channel_names=channel_names,
z=self.z_index,
Expand All @@ -325,7 +325,7 @@ def __set_image(self):
c=channel,
series=series,
index=index,
rescale=self.rescale,
rescale=self.rescale if isinstance(self.rescale, bool) else False,
wants_max_intensity=True,
channel_names=channel_names,
z=self.z_index,
Expand All @@ -341,6 +341,7 @@ def __set_image(self):
path_name=self.get_pathname(),
file_name=self.get_filename(),
scale=self.scale,
channelstack=img.ndim == 3 and img.shape[-1]>3
)
if img.ndim == 3 and len(channel_names) == img.shape[2]:
self.__image.channel_names = list(channel_names)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ def provide_image(self, image_set):
image = URLImage.provide_image(self, image_set)

if image.pixel_data.ndim == image.dimensions:
image.pixel_data = skimage.color.gray2rgb(image.pixel_data, alpha=False)
image.pixel_data = skimage.color.gray2rgb(image.pixel_data)

return image
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def get_indexes(self, url):

def get_image_volume(self):
imdata = self.__data
planes = [] # newplanes = numpy.zeros_like(test2)
planes = []
for planeid in range(imdata.shape[0]):
planes.append(convert_image_to_objects(imdata[planeid]).astype(numpy.int32))
planes.append(imdata[planeid].astype(numpy.int32))
imdata = numpy.stack(planes)

image = Image(
Expand Down
25 changes: 23 additions & 2 deletions cellprofiler_core/measurement/_measurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
from ..constants.measurement import C_PATH_NAME
from ..constants.measurement import C_SERIES
from ..constants.measurement import C_URL
from ..constants.measurement import DB_TEMP
from ..constants.measurement import EXPERIMENT
from ..constants.measurement import GROUP_INDEX
from ..constants.measurement import GROUP_NUMBER
from ..constants.measurement import GROUP_LENGTH
from ..constants.measurement import IMAGE
from ..constants.measurement import IMAGE_NUMBER
from ..constants.measurement import K_CASE_SENSITIVE
Expand Down Expand Up @@ -364,6 +366,15 @@ def set_group_index(self, group_index):

group_index = property(get_group_index, set_group_index)

def get_group_length(self):
"""The group length of the current image group"""
return self.get_current_image_measurement(GROUP_LENGTH)

def set_group_length(self, group_length):
self.add_image_measurement(GROUP_LENGTH, group_length)

group_length = property(get_group_length, set_group_length)

def get_groupings(self, features):
"""Return groupings of image sets based on feature values

Expand Down Expand Up @@ -741,7 +752,7 @@ def clear(self):
def get_object_names(self):
"""The list of object names (including Image) that have measurements
"""
return [x for x in self.hdf5_dict.top_level_names() if x != RELATIONSHIP]
return [x for x in self.hdf5_dict.top_level_names() if x not in (DB_TEMP, RELATIONSHIP)]

object_names = property(get_object_names)

Expand Down Expand Up @@ -1295,6 +1306,7 @@ def write_image_sets(self, fd_or_file, start=None, stop=None):
to_save = [
GROUP_NUMBER,
GROUP_INDEX,
GROUP_LENGTH
]
to_save_prefixes = [
C_URL,
Expand Down Expand Up @@ -1733,11 +1745,20 @@ def set_grouping_tags(self, grouping_tags):
data = json.dumps(grouping_tags)
self.add_experiment_measurement(M_GROUPING_TAGS, data)

def get_grouping_tags(self):
def get_grouping_tags_or_metadata(self):
"""Get the metadata tags that were used to group the image set

"""
if not self.has_feature(EXPERIMENT, M_GROUPING_TAGS,):
return self.get_metadata_tags()

return json.loads(self.get_experiment_measurement(M_GROUPING_TAGS))

def get_grouping_tags_only(self):
"""Get the metadata tags that were used to group the image set,
and only those, not metadata instead
"""
if not self.has_feature(EXPERIMENT, M_GROUPING_TAGS,):
return []

return json.loads(self.get_experiment_measurement(M_GROUPING_TAGS))
8 changes: 6 additions & 2 deletions cellprofiler_core/module/_module.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import abc
import logging
import sys
import uuid

Expand Down Expand Up @@ -106,12 +107,15 @@ def from_dict(self, settings: list, attributes: dict):
self.wants_pause = attributes["wants_pause"]
self.svn_version = attributes["svn_version"]
self.enabled = attributes["enabled"]
self.variable_revision_number = attributes["variable_revision_number"]
self.module_path = attributes["module_path"]
self.module_name = attributes["module_name"]
setting_values = [setting["value"] for setting in settings]
if attributes["variable_revision_number"] > self.variable_revision_number:
logging.warning(f"Loaded module '{self.module_name}' is from a newer version of CellProfiler - "
f"v{attributes['variable_revision_number']}, current version is "
f"v{self.variable_revision_number}. Settings may load incorrectly.")
self.set_settings_from_values(
setting_values, self.variable_revision_number, self.module_path
setting_values, attributes['variable_revision_number'], self.module_path
)

@abc.abstractmethod
Expand Down
22 changes: 17 additions & 5 deletions cellprofiler_core/modules/groups.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy

from ..constants.measurement import COLTYPE_VARCHAR
from ..constants.measurement import COLTYPE_INTEGER, COLTYPE_VARCHAR, IMAGE
from ..constants.measurement import C_FILE_NAME
from ..constants.measurement import C_METADATA
from ..constants.measurement import C_OBJECTS_FILE_NAME
Expand All @@ -9,6 +9,7 @@
from ..constants.measurement import EXPERIMENT
from ..constants.measurement import GROUP_INDEX
from ..constants.measurement import GROUP_NUMBER
from ..constants.measurement import GROUP_LENGTH
from ..constants.measurement import M_GROUPING_TAGS
from ..measurement import Measurements
from ..module import Module
Expand Down Expand Up @@ -559,7 +560,7 @@ def get_groupings(self, workspace):
"""
if not self.wants_groups:
return
key_list = self.get_grouping_tags()
key_list = self.get_grouping_tags_or_metadata()
m = workspace.measurements
for key in key_list:
if key not in m.get_feature_names("Image"):
Expand All @@ -577,7 +578,7 @@ def get_groupings(self, workspace):
return None
return key_list, m.get_groupings(key_list)

def get_grouping_tags(self):
def get_grouping_tags_or_metadata(self):
"""Return the metadata keys used for grouping"""
if not self.wants_groups:
return None
Expand Down Expand Up @@ -642,12 +643,19 @@ def prepare_run(self, workspace, changed_setting = False):
group_indexes = numpy.hstack(
[numpy.arange(len(image_numbers)) + 1 for keys, image_numbers in groupings]
)
group_lens = numpy.hstack(
[
numpy.ones(len(image_numbers), int) * (len(image_numbers))
for i, (keys, image_numbers) in enumerate(groupings)
]
)
image_numbers = numpy.hstack(
[image_numbers for keys, image_numbers in groupings]
)
order = numpy.lexsort((group_indexes, group_numbers))
group_numbers = group_numbers[order]
group_indexes = group_indexes[order]
group_lens = group_lens[order]

m = workspace.measurements
assert isinstance(m, Measurements)
Expand All @@ -664,7 +672,10 @@ def prepare_run(self, workspace, changed_setting = False):
m.add_all_measurements(
"Image", GROUP_INDEX, group_indexes,
)
m.set_grouping_tags(self.get_grouping_tags())
m.add_all_measurements(
"Image", GROUP_LENGTH, group_lens,
)
m.set_grouping_tags(self.get_grouping_tags_or_metadata())
return True

def run(self, workspace):
Expand All @@ -678,12 +689,13 @@ def get_measurement_columns(self, pipeline):
result = []
if self.wants_groups:
result.append((EXPERIMENT, M_GROUPING_TAGS, COLTYPE_VARCHAR,))
result.append((IMAGE, GROUP_LENGTH, COLTYPE_INTEGER))
#
# These are bound to be produced elsewhere, but it is quite
# computationally expensive to find that out. If they are
# duplicated by another module, no big deal.
#
for ftr in self.get_grouping_tags():
for ftr in self.get_grouping_tags_or_metadata():
result.append(("Image", ftr, COLTYPE_VARCHAR,))
return result

Expand Down
5 changes: 3 additions & 2 deletions cellprofiler_core/modules/loaddata.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ..constants.measurement import FTR_WELL
from ..constants.measurement import M_WELL
from ..constants.measurement import PATH_NAME_LENGTH
from ..constants.measurement import GROUP_LENGTH
from ..constants.module import IO_FOLDER_CHOICE_HELP_TEXT
from ..constants.modules.load_data import DIR_ALL
from ..constants.modules.load_data import IMAGE_CATEGORIES
Expand Down Expand Up @@ -953,12 +954,12 @@ def prepare_run(self, workspace):
for eachval in groupvals:
group_lengths += [len(eachval[1])] * len(eachval[1])
m.add_all_measurements(
"Image", "Group_Length", group_lengths,
"Image", GROUP_LENGTH, group_lengths,
)
else:
group_lengths = [len(rows)] * len(rows)
m.add_all_measurements(
"Image", "Group_Length", group_lengths,
"Image", GROUP_LENGTH, group_lengths,
)

return True
Expand Down
Loading
Loading