-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create image masks for NF1 test data (#56)
* add cppipe file for nf1 mask export Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * update to use image instead of mask export Co-Authored-By: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com> * create masks using cellprofiler through docker cli * linting --------- Co-authored-by: Jenna Tomkinson <107513215+jenna-tomkinson@users.noreply.github.com>
- Loading branch information
1 parent
c9bb29b
commit b0957e3
Showing
19 changed files
with
280 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
227 changes: 227 additions & 0 deletions
227
tests/data/cytotable/NF1_cellpainting_data_shrunken/NF1_plate2_export_masks.cppipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,227 @@ | ||
CellProfiler Pipeline: http://www.cellprofiler.org | ||
Version:5 | ||
DateRevision:424 | ||
GitHash: | ||
ModuleCount:13 | ||
HasImagePlaneDetails:False | ||
|
||
Images:[module_num:1|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['Images module is left blank as we are giving the path to the corrected images in the CLI']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
: | ||
Filter images?:Images only | ||
Select the rule criteria:and (extension does isimage) (directory doesnot containregexp "[\\\\/]\\.") | ||
|
||
Metadata:[module_num:2|svn_version:'Unknown'|variable_revision_number:6|show_window:False|notes:['Extract metadata from file names and folder names using regular expressions.', '', 'The only metadata that will be outputed in the SQLite DB file are:', '', 'Plate', 'Well', 'Site', '', 'The rest of the information is useful to make sure that the expression is working, but can be removed/not necessary.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Extract metadata?:Yes | ||
Metadata data type:Text | ||
Metadata types:{"Channel": "integer", "FileLocation": "text", "Frame": "text", "Plate": "text", "Series": "text", "Site": "integer", "Stain": "float", "Well": "text"} | ||
Extraction method count:2 | ||
Metadata extraction method:Extract from file/folder names | ||
Metadata source:File name | ||
Regular expression to extract from file name:(?P<Well>[A-Z]{1}[0-9]{1,2})_01_(?P<Channel>[1-3]{1})_(?P<Site>[1-4]{1})_(?P<Stain>DAPI|GFP|RFP) | ||
Regular expression to extract from folder name:(?P<Date>[0-9]{4}_[0-9]{2}_[0-9]{2})$ | ||
Extract metadata from:All images | ||
Select the filtering criteria:and (file does contain "") | ||
Metadata file location:Elsewhere...| | ||
Match file and image metadata:[] | ||
Use case insensitive matching?:No | ||
Metadata file name:None | ||
Does cached metadata exist?:No | ||
Metadata extraction method:Extract from file/folder names | ||
Metadata source:Folder name | ||
Regular expression to extract from file name:^(?P<Plate>.*)_(?P<Well>[A-P][0-9]{2})_s(?P<Site>[0-9])_w(?P<ChannelNumber>[0-9]) | ||
Regular expression to extract from folder name:Corrected_(?P<Plate>Plate_[0-9]{1}) | ||
Extract metadata from:All images | ||
Select the filtering criteria:and (file does contain "") | ||
Metadata file location:Elsewhere...| | ||
Match file and image metadata:[] | ||
Use case insensitive matching?:No | ||
Metadata file name:None | ||
Does cached metadata exist?:No | ||
|
||
NamesAndTypes:[module_num:3|svn_version:'Unknown'|variable_revision_number:8|show_window:False|notes:['Assign files to their respective channel (only 3):', '', 'DAPI', 'GFP', 'RFP']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Assign a name to:Images matching rules | ||
Select the image type:Grayscale image | ||
Name to assign these images:DNA | ||
Match metadata:[] | ||
Image set matching method:Order | ||
Set intensity range from:Image metadata | ||
Assignments count:3 | ||
Single images count:0 | ||
Maximum intensity:255.0 | ||
Process as 3D?:No | ||
Relative pixel spacing in X:1.0 | ||
Relative pixel spacing in Y:1.0 | ||
Relative pixel spacing in Z:1.0 | ||
Select the rule criteria:and (file does contain "DAPI") | ||
Name to assign these images:DAPI | ||
Name to assign these objects:Cell | ||
Select the image type:Grayscale image | ||
Set intensity range from:Image metadata | ||
Maximum intensity:255.0 | ||
Select the rule criteria:and (file does contain "GFP") | ||
Name to assign these images:GFP | ||
Name to assign these objects:Nucleus | ||
Select the image type:Grayscale image | ||
Set intensity range from:Image metadata | ||
Maximum intensity:255.0 | ||
Select the rule criteria:and (file does contain "RFP") | ||
Name to assign these images:RFP | ||
Name to assign these objects:Cytoplasm | ||
Select the image type:Grayscale image | ||
Set intensity range from:Image metadata | ||
Maximum intensity:255.0 | ||
|
||
Groups:[module_num:4|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['We do not use the Groups module.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Do you want to group your images?:No | ||
grouping metadata count:1 | ||
Metadata category:None | ||
|
||
IdentifyPrimaryObjects:[module_num:5|svn_version:'Unknown'|variable_revision_number:15|show_window:False|notes:['These are the current best parameters to segment nuclei from the DAPI channel']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the input image:DAPI | ||
Name the primary objects to be identified:Nuclei | ||
Typical diameter of objects, in pixel units (Min,Max):30,90 | ||
Discard objects outside the diameter range?:Yes | ||
Discard objects touching the border of the image?:Yes | ||
Method to distinguish clumped objects:None | ||
Method to draw dividing lines between clumped objects:Shape | ||
Size of smoothing filter:10 | ||
Suppress local maxima that are closer than this minimum allowed distance:7.0 | ||
Speed up by using lower-resolution image to find local maxima?:Yes | ||
Fill holes in identified objects?:After both thresholding and declumping | ||
Automatically calculate size of smoothing filter for declumping?:Yes | ||
Automatically calculate minimum allowed distance between local maxima?:Yes | ||
Handling of objects if excessive number of objects identified:Continue | ||
Maximum number of objects:500 | ||
Use advanced settings?:Yes | ||
Threshold setting version:12 | ||
Threshold strategy:Global | ||
Thresholding method:Otsu | ||
Threshold smoothing scale:1.3488 | ||
Threshold correction factor:1.0 | ||
Lower and upper bounds on threshold:0.0,1.0 | ||
Manual threshold:0.0 | ||
Select the measurement to threshold with:None | ||
Two-class or three-class thresholding?:Three classes | ||
Log transform before thresholding?:No | ||
Assign pixels in the middle intensity class to the foreground or the background?:Foreground | ||
Size of adaptive window:50 | ||
Lower outlier fraction:0.05 | ||
Upper outlier fraction:0.05 | ||
Averaging method:Mean | ||
Variance method:Standard deviation | ||
# of deviations:2.0 | ||
Thresholding method:Minimum Cross-Entropy | ||
|
||
IdentifySecondaryObjects:[module_num:6|svn_version:'Unknown'|variable_revision_number:10|show_window:False|notes:['These are the current best parameters to segment whole cells using the RFP (actin) channel']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the input objects:Nuclei | ||
Name the objects to be identified:Cells | ||
Select the method to identify the secondary objects:Propagation | ||
Select the input image:RFP | ||
Number of pixels by which to expand the primary objects:10 | ||
Regularization factor:0.05 | ||
Discard secondary objects touching the border of the image?:Yes | ||
Discard the associated primary objects?:No | ||
Name the new primary objects:Nuclei | ||
Fill holes in identified objects?:Yes | ||
Threshold setting version:12 | ||
Threshold strategy:Global | ||
Thresholding method:Otsu | ||
Threshold smoothing scale:1.3488 | ||
Threshold correction factor:1.0 | ||
Lower and upper bounds on threshold:0.0,1.0 | ||
Manual threshold:0.0 | ||
Select the measurement to threshold with:None | ||
Two-class or three-class thresholding?:Three classes | ||
Log transform before thresholding?:No | ||
Assign pixels in the middle intensity class to the foreground or the background?:Foreground | ||
Size of adaptive window:50 | ||
Lower outlier fraction:0.05 | ||
Upper outlier fraction:0.05 | ||
Averaging method:Mean | ||
Variance method:Standard deviation | ||
# of deviations:2.0 | ||
Thresholding method:Otsu | ||
|
||
IdentifyTertiaryObjects:[module_num:7|svn_version:'Unknown'|variable_revision_number:3|show_window:False|notes:['This module creates a third object from the first two where the nuclei is subtracted from the cells to create cytoplasm']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the larger identified objects:Cells | ||
Select the smaller identified objects:Nuclei | ||
Name the tertiary objects to be identified:Cytoplasm | ||
Shrink smaller object prior to subtraction?:Yes | ||
|
||
ConvertObjectsToImage:[module_num:8|svn_version:'Unknown'|variable_revision_number:1|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the input objects:Nuclei | ||
Name the output image:MaskNuclei | ||
Select the color format:Binary (black & white) | ||
Select the colormap:Default | ||
|
||
ConvertObjectsToImage:[module_num:9|svn_version:'Unknown'|variable_revision_number:1|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the input objects:Cells | ||
Name the output image:MaskCells | ||
Select the color format:Binary (black & white) | ||
Select the colormap:Default | ||
|
||
ConvertObjectsToImage:[module_num:10|svn_version:'Unknown'|variable_revision_number:1|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the input objects:Cytoplasm | ||
Name the output image:MaskCytoplasm | ||
Select the color format:Binary (black & white) | ||
Select the colormap:Default | ||
|
||
SaveImages:[module_num:11|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the type of image to save:Image | ||
Select the image to save:MaskNuclei | ||
Select method for constructing file names:From image filename | ||
Select image name for file prefix:DAPI | ||
Enter single file name:OrigBlue | ||
Number of digits:4 | ||
Append a suffix to the image file name?:Yes | ||
Text to append to the image name:_MaskNuclei | ||
Saved file format:tiff | ||
Output file location:Default Output Folder| | ||
Image bit depth:8-bit integer | ||
Overwrite existing files without warning?:No | ||
When to save:Every cycle | ||
Record the file and path information to the saved image?:No | ||
Create subfolders in the output folder?:No | ||
Base image folder:Elsewhere...| | ||
How to save the series:T (Time) | ||
Save with lossless compression?:Yes | ||
|
||
SaveImages:[module_num:12|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the type of image to save:Image | ||
Select the image to save:MaskCells | ||
Select method for constructing file names:From image filename | ||
Select image name for file prefix:RFP | ||
Enter single file name:OrigBlue | ||
Number of digits:4 | ||
Append a suffix to the image file name?:Yes | ||
Text to append to the image name:_MaskCells | ||
Saved file format:tiff | ||
Output file location:Default Output Folder| | ||
Image bit depth:8-bit integer | ||
Overwrite existing files without warning?:No | ||
When to save:Every cycle | ||
Record the file and path information to the saved image?:No | ||
Create subfolders in the output folder?:No | ||
Base image folder:Elsewhere...| | ||
How to save the series:T (Time) | ||
Save with lossless compression?:Yes | ||
|
||
SaveImages:[module_num:13|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:[]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False] | ||
Select the type of image to save:Image | ||
Select the image to save:MaskCytoplasm | ||
Select method for constructing file names:From image filename | ||
Select image name for file prefix:RFP | ||
Enter single file name:OrigBlue | ||
Number of digits:4 | ||
Append a suffix to the image file name?:Yes | ||
Text to append to the image name:_MaskCytoplasm | ||
Saved file format:tiff | ||
Output file location:Default Output Folder| | ||
Image bit depth:8-bit integer | ||
Overwrite existing files without warning?:No | ||
When to save:Every cycle | ||
Record the file and path information to the saved image?:No | ||
Create subfolders in the output folder?:No | ||
Base image folder:Elsewhere...| | ||
How to save the series:T (Time) | ||
Save with lossless compression?:Yes |
Binary file added
BIN
+7.08 KB
...cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/B7_01_1_3_DAPI_001_MaskNuclei.tiff
Binary file not shown.
Binary file added
BIN
+10.5 KB
...a/cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/B7_01_3_3_RFP_001_MaskCells.tiff
Binary file not shown.
Binary file added
BIN
+13.2 KB
...totable/NF1_cellpainting_data_shrunken/Plate_2_masks/B7_01_3_3_RFP_001_MaskCytoplasm.tiff
Binary file not shown.
Binary file added
BIN
+7.97 KB
...cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/D6_01_1_2_DAPI_001_MaskNuclei.tiff
Binary file not shown.
Binary file added
BIN
+13.3 KB
...a/cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/D6_01_3_2_RFP_001_MaskCells.tiff
Binary file not shown.
Binary file added
BIN
+15.9 KB
...totable/NF1_cellpainting_data_shrunken/Plate_2_masks/D6_01_3_2_RFP_001_MaskCytoplasm.tiff
Binary file not shown.
Binary file added
BIN
+7.57 KB
...cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/D7_01_1_1_DAPI_001_MaskNuclei.tiff
Binary file not shown.
Binary file added
BIN
+16.7 KB
...a/cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/D7_01_3_1_RFP_001_MaskCells.tiff
Binary file not shown.
Binary file added
BIN
+19.6 KB
...totable/NF1_cellpainting_data_shrunken/Plate_2_masks/D7_01_3_1_RFP_001_MaskCytoplasm.tiff
Binary file not shown.
Binary file added
BIN
+6.24 KB
...cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/F7_01_1_2_DAPI_001_MaskNuclei.tiff
Binary file not shown.
Binary file added
BIN
+14.1 KB
...a/cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/F7_01_3_2_RFP_001_MaskCells.tiff
Binary file not shown.
Binary file added
BIN
+16 KB
...totable/NF1_cellpainting_data_shrunken/Plate_2_masks/F7_01_3_2_RFP_001_MaskCytoplasm.tiff
Binary file not shown.
Binary file added
BIN
+6.27 KB
...ytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/H12_01_1_1_DAPI_001_MaskNuclei.tiff
Binary file not shown.
Binary file added
BIN
+14 KB
.../cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks/H12_01_3_1_RFP_001_MaskCells.tiff
Binary file not shown.
Binary file added
BIN
+16.4 KB
...otable/NF1_cellpainting_data_shrunken/Plate_2_masks/H12_01_3_1_RFP_001_MaskCytoplasm.tiff
Binary file not shown.
File renamed without changes.
51 changes: 51 additions & 0 deletions
51
tests/data/cytotable/NF1_cellpainting_data_shrunken/create_mask_data.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
""" | ||
Creates image masks for images in | ||
coSMicQC/tests/data/cytotable/NF1_cellpainting_data (Plate 2) | ||
Note: expects Docker to be installed as a CLI on the system. | ||
This file may be processed using the following command from the root | ||
of the project repository: | ||
`poetry run python \ | ||
tests/data/cytotable/NF1_cellpainting_data_shrunken/create_mask_data.py` | ||
""" | ||
|
||
import os | ||
import pathlib | ||
import subprocess | ||
|
||
# create a dir for segmentation masks | ||
pathlib.Path("tests/data/cytotable/NF1_cellpainting_data_shrunken/Plate_2_masks").mkdir( | ||
exist_ok=True | ||
) | ||
|
||
# define docker command for CellProfiler use with provided pipeline file | ||
command = [ | ||
"docker", | ||
"run", | ||
"--platform", | ||
"linux/amd64", | ||
"--rm", | ||
"-v", | ||
f"{os.getcwd()}/tests/data/cytotable/NF1_cellpainting_data_shrunken:/app", | ||
"cellprofiler/cellprofiler:4.2.4", | ||
"cellprofiler", | ||
"-c", | ||
"-r", | ||
"-p", | ||
"/app/NF1_plate2_export_masks.cppipe", | ||
"-o", | ||
"/app/Plate_2_masks", | ||
"-i", | ||
"/app/Plate_2_images", | ||
] | ||
|
||
# Run the command and show output | ||
try: | ||
result = subprocess.run(command, check=True, text=True, capture_output=True) | ||
print("Command Output:\n", result.stdout) | ||
print("Command Error:\n", result.stderr) | ||
except subprocess.CalledProcessError as e: | ||
print("Error:", e) | ||
print("Command Output:\n", e.stdout) | ||
print("Command Error:\n", e.stderr) |