Skip to content

Commit

Permalink
Merge pull request #48 from BodenmillerGroup/develop-cp4
Browse files Browse the repository at this point in the history
Fixes wrong suffix appending for compensated measurements
  • Loading branch information
votti authored Nov 23, 2020
2 parents d14624f + 45db328 commit a53bb7e
Show file tree
Hide file tree
Showing 9 changed files with 1,549 additions and 30 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: CI

on:
push:
branches: [ master ]
branches: [ master, develop-cp4 ]
pull_request:
branches: [ master ]
branches: [ master, develop-cp4 ]

jobs:
build:
Expand All @@ -32,5 +32,7 @@ jobs:

- uses: actions/checkout@1.0.0
- uses: excitedleigh/setup-nox@1.0.0
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
- name: Test with nox
run: nox
65 changes: 46 additions & 19 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.. image:: https://zenodo.org/badge/69028464.svg
:target: https://zenodo.org/badge/latestdoi/69028464

ImcPluginsCP
========================

Expand All @@ -14,15 +15,27 @@ analyzed plane-by-plane but as a stack). This modules help Cellprofiler to bette
Their main use have been the associated multiplexed image segmentation pipeline (https://github.com/BodenmillerGroup/ImcSegmentationPipeline)
and projects using this workflow.

Changenotes:
-----------
The modules have been updated to work with *CellProfiler 4* instead of *CellProfiler 3 or 2*!
The CP2 and CP3 modules are still available at the branch:
- https://github.com/BodenmillerGroup/ImcPluginsCP/tree/master-cp2
- https://github.com/BodenmillerGroup/ImcPluginsCP/tree/master-cp3
Changelog:
------------
- 2020-11-20: Fixes a bug in CorrectSpilloverMeasurements introduced by the
CP3 -> CP4 transition that caused the the name suffix to be appended
to the image instead of the measurement name.

- 2020-11-18: ExportVarCsv now also adds column metadata for the Image table.

- 2020-11-13: Adds new ExportVarCsv module
This module parses measurement names from output tables into a
clean metadata file that should facilitate the import of cellprofiler
output into anndata.

Several modules have been deprecated or changed names. Please read the 'deprecation' notes displayed when
loading these modules to see if and how you need to adapt your pipeline.
- 2020-10-30:
The modules have been updated to work with *CellProfiler 4* instead of *CellProfiler 3 or 2*!
The CP2 and CP3 modules are still available at the branch:
- https://github.com/BodenmillerGroup/ImcPluginsCP/tree/master-cp2
- https://github.com/BodenmillerGroup/ImcPluginsCP/tree/master-cp3

Several modules have been deprecated or changed names. Please read the 'deprecation' notes displayed when
loading these modules to see if and how you need to adapt your pipeline.

General Information
-------------------
Expand All @@ -37,7 +50,7 @@ For installation copy the folder to a local directory,
modify the CellProfiler `Preferences` in the GUI to the plugin folder (`PATHTO/ImcPluginsCP/plugins`) and **restart** cellprofiler.

For command line usage use the command line flag: `--plugins-directory=PATHTO/ImcPluginsCP/plugins`

The modules
-------------------

Expand All @@ -54,13 +67,22 @@ Measurement modules:
The number of planes in the stack needs to be known and indicated beforehand.
The name of the measurements will have a suffix `_c{channelnr}` where channelnr is 1 based index of the plane.

* ExportVarCsv:
Exports a CSV containing metadata for measurements akin to the .var table
in anndata objects: https://anndata.readthedocs.io/en/latest/anndata.AnnData.html
This should greatly facilitate the conversion of cellprofiler output to
anndata objects.

Image processing modules:

* Smooth Multichannel: allows to apply image filters to all stacks of a multichannel image
* Smooth Multichannel:
allows to apply image filters to all stacks of a multichannel image
Very similar to the normal *Smooth* module.
Additionally provides filters:
- "Remove single hot pixels" (good for single, strong outliers)
- "Median Filter Scipy": Fixes a bug of the normal Median filter when small footprints are used.

- "Remove single hot pixels" (good for single, strong outliers)

- "Median Filter Scipy": Fixes a bug of the normal Median filter when small footprints are used.

* ClipRange:
Clips the maximum of an image by setting all values higher than an user defined percentile to the value of said percentile.
Expand Down Expand Up @@ -129,7 +151,7 @@ Spillover related modules:
Module: *CorrectSpilloverMeasurements*.

* CorrectSpilloverMeasurements:
applies an spillover matrix to measurments multichannel image to account for channel crosstalk (spillover)
applies an spillover matrix to measurements multichannel image to account for channel crosstalk (spillover)

This module applies a previously calculate spillover matrix, loaded as a normal image.
The spillover matrix is a float image with dimensions p*p (p=number of color channels).
Expand All @@ -147,20 +169,25 @@ Spillover related modules:
in all channels (e.g. MeanIntensity) but not others (e.g. MedianIntensity, MaxIntensity, StdIntensity...).
For measurements where this applies, applying the compensation to *Measurements* is usually more accurate than compensating an image
and then measuring.
For measurments where this does not apply, please measure the image compensated with Module: *CorrectSpilloverApply*.
For measurements where this does not apply, please measure the image compensated with Module: *CorrectSpilloverApply*.


Pleas read also the documetation within CellProfiler for more hints how to use these modules!
Pleas read also the documentation within CellProfiler for more hints how to use these modules!

Deprecated modules:
___________________
This will be removed in the next version of ImcPluginsCP.

* ColorToGray bb: a slight modification of the 'ColorToGray' CP module to support up to 60 channels per image
* ColorToGray bb:
a slight modification of the 'ColorToGray' CP module to support up to 60 channels per image
-> Can be replaced by default *ColorToGray* module

* Rescale objects: Rescales object segmentation masks
* Rescale objects:
Rescales object segmentation masks
-> Can be replaced by the default *ResizeObjects* module

* Save images ilastik: a helper module to save images as `.tiff` in a way that ilastik 1.2.1 will recognize it as xyc image
-> This will is deprecated. I recommend to use the *saveimages_h5` module for this task and use `hdf5` instead of tiff
* Save images ilastik:
a helper module to save images as `.tiff` in a way that ilastik 1.2.1 will recognize it as xyc image
-> This will is deprecated. I recommend to use the *saveimages_h5* module
for this task and use `hdf5` instead of tiff

2 changes: 1 addition & 1 deletion plugins/correctspilloverapply.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def add_image(self, can_delete=True):
)
spill_correct_method = cps.choice.Choice(
"Spillover correction method",
[METHOD_LS, METHOD_NNLS],
[METHOD_NNLS, METHOD_LS],
doc="""
Select the spillover correction method.
<ul>
Expand Down
11 changes: 6 additions & 5 deletions plugins/correctspillovermeasurements.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_valid(self, pipeline):

class CorrectSpilloverMeasurements(cpm.Module):
category = ["ImcPluginsCP", "Measurement"]
variable_revision_number = 3
variable_revision_number = 5
module_name = "CorrectSpilloverMeasurements"

def create_settings(self):
Expand Down Expand Up @@ -91,7 +91,7 @@ def add_compmeasurement(self, can_delete=True):
)
spill_correct_method = cps.choice.Choice(
"Spillover correction method",
[METHOD_LS, METHOD_NNLS],
[METHOD_NNLS, METHOD_LS],
doc="""
Select the spillover correction method.
<ul>
Expand Down Expand Up @@ -223,11 +223,12 @@ def _get_compmeasurement_output_columns(self, nchan, cm):
return outcols

def _generate_outcolname(self, colname, suffix):
colfrag = colname.split("_c")
colfrag[-2] += suffix
outcol = "_c".join(colfrag)
colfrag = colname.split('_')
colfrag[1] += suffix
outcol = '_'.join(colfrag)
return outcol


def get_measurement_columns(self, pipeline):
"""Return column definitions for compmeasurements made by this module"""
columns = []
Expand Down
Loading

0 comments on commit a53bb7e

Please sign in to comment.