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

Create IC module #3

Merged
merged 5 commits into from
Mar 16, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# ignore all plates as they are downloaded from figshare in instructions, including the metadata folder created
# ignore all plates as they are downloaded from figshare in instructions
0.download_data/Plate_1
0.download_data/Plate_2

# ignore pycache
__pycache__

# ignore corrected plates images (like in download data
1.cellprofiler_ic/Corrected_Plate_1
1.cellprofiler_ic/Corrected_Plate_2
3 changes: 2 additions & 1 deletion 0.download_data/download_plates.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"outputs": [],
"source": [
"import pathlib\n",
"from download_figshare import download_figshare"
"\n",
"from utils.download_figshare import download_figshare"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion 0.download_data/scripts/download_plates.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@


import pathlib
from download_figshare import download_figshare
from utils.download_figshare import download_figshare


# ## Set constant paths/variables
Expand Down
217 changes: 217 additions & 0 deletions 1.cellprofiler_ic/NF1_illum.cppipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
CellProfiler Pipeline: http://www.cellprofiler.org
Version:5
DateRevision:424
GitHash:
ModuleCount:11
HasImagePlaneDetails:False

Images:[module_num:1|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['To begin creating your project, use the Images module to compile a list of files and/or folders that you want to analyze. You can also specify a set of rules to include only the desired files in your selected folders.']|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:['The Metadata module optionally allows you to extract information describing your images (i.e, metadata) which will be stored along with your measurements. This information can be contained in the file name and/or location, or in an external file.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Extract metadata?:No
Metadata data type:Text
Metadata types:{}
Extraction method count:1
Metadata extraction method:Extract from file/folder names
Metadata source:File 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:(?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

NamesAndTypes:[module_num:3|svn_version:'Unknown'|variable_revision_number:8|show_window:False|notes:['The NamesAndTypes module allows you to assign a meaningful name to each image by which other modules will refer to it.']|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:OrigDAPI
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:OrigGFP
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:OrigRFP
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:['The Groups module optionally allows you to split your list of images into image subsets (groups) which will be processed independently of each other. Examples of groupings include screening batches, microtiter plates, time-lapse movies, etc.']|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

CorrectIlluminationCalculate:[module_num:5|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['Create an IC function for each image and we use the Background (due to majority of the images have less objects taking up the images) + Fit Polynomial smoothing method as this seems to work well at this time.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the input image:OrigDAPI
Name the output image:IllumDAPI
Select how the illumination function is calculated:Background
Dilate objects in the final averaged image?:No
Dilation radius:1
Block size:50
Rescale the illumination function?:Yes
Calculate function for each image individually, or based on all images?:Each
Smoothing method:Fit Polynomial
Method to calculate smoothing filter size:Automatic
Approximate object diameter:80
Smoothing filter size:200
Retain the averaged image?:No
Name the averaged image:IllumBlueAvg
Retain the dilated image?:No
Name the dilated image:IllumBlueDilated
Automatically calculate spline parameters?:No
Background mode:dark
Number of spline points:5
Background threshold:2.0
Image resampling factor:2.0
Maximum number of iterations:40
Residual value for convergence:0.001

CorrectIlluminationCalculate:[module_num:6|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['Create an IC function for each image and we use the Background (due to majority of the images have less objects taking up the images) + Fit Polynomial smoothing method as this seems to work well at this time.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the input image:OrigGFP
Name the output image:IllumGFP
Select how the illumination function is calculated:Background
Dilate objects in the final averaged image?:No
Dilation radius:1
Block size:50
Rescale the illumination function?:Yes
Calculate function for each image individually, or based on all images?:Each
Smoothing method:Fit Polynomial
Method to calculate smoothing filter size:Automatic
Approximate object diameter:200
Smoothing filter size:200
Retain the averaged image?:No
Name the averaged image:IllumBlueAvg
Retain the dilated image?:No
Name the dilated image:IllumBlueDilated
Automatically calculate spline parameters?:Yes
Background mode:auto
Number of spline points:5
Background threshold:2.0
Image resampling factor:2.0
Maximum number of iterations:40
Residual value for convergence:0.001

CorrectIlluminationCalculate:[module_num:7|svn_version:'Unknown'|variable_revision_number:2|show_window:False|notes:['Create an IC function for each image and we use the Background (due to majority of the images have less objects taking up the images) + Fit Polynomial smoothing method as this seems to work well at this time.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the input image:OrigRFP
Name the output image:IllumRFP
Select how the illumination function is calculated:Background
Dilate objects in the final averaged image?:No
Dilation radius:1
Block size:50
Rescale the illumination function?:Yes
Calculate function for each image individually, or based on all images?:Each
Smoothing method:Fit Polynomial
Method to calculate smoothing filter size:Automatic
Approximate object diameter:10
Smoothing filter size:600
Retain the averaged image?:No
Name the averaged image:IllumBlueAvg
Retain the dilated image?:No
Name the dilated image:IllumBlueDilated
Automatically calculate spline parameters?:Yes
Background mode:auto
Number of spline points:5
Background threshold:2.0
Image resampling factor:2.0
Maximum number of iterations:40
Residual value for convergence:0.001

CorrectIlluminationApply:[module_num:8|svn_version:'Unknown'|variable_revision_number:5|show_window:False|notes:['Apply illumination correction functions to all channel groups']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the input image:OrigDAPI
Name the output image:CorrDAPI
Select the illumination function:IllumDAPI
Select how the illumination function is applied:Divide
Select the input image:OrigGFP
Name the output image:CorrGFP
Select the illumination function:IllumGFP
Select how the illumination function is applied:Divide
Select the input image:OrigRFP
Name the output image:CorrRFP
Select the illumination function:IllumRFP
Select how the illumination function is applied:Divide
Set output image values less than 0 equal to 0?:Yes
Set output image values greater than 1 equal to 1?:Yes

SaveImages:[module_num:9|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:['Save DAPI images as same tiff bit depth']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the type of image to save:Image
Select the image to save:CorrDAPI
Select method for constructing file names:From image filename
Select image name for file prefix:OrigDAPI
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:_illumcorrect
Saved file format:tiff
Output file location:Default Output Folder|NF1_SchwannCell_data/CellProfiler_pipelines/IC_Output
Image bit depth:16-bit integer
Overwrite existing files without warning?:Yes
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:10|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:['Save GFP images as same bit depth']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the type of image to save:Image
Select the image to save:CorrGFP
Select method for constructing file names:From image filename
Select image name for file prefix:OrigGFP
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:_illumcorrect
Saved file format:tiff
Output file location:Default Output Folder|NF1_SchwannCell_data/CellProfiler_pipelines/IC_Output
Image bit depth:16-bit integer
Overwrite existing files without warning?:Yes
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:11|svn_version:'Unknown'|variable_revision_number:16|show_window:False|notes:['Save RFP images as same bit depth']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
Select the type of image to save:Image
Select the image to save:CorrRFP
Select method for constructing file names:From image filename
Select image name for file prefix:OrigRFP
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:_illumcorrect
Saved file format:tiff
Output file location:Default Output Folder|NF1_SchwannCell_data/CellProfiler_pipelines/IC_Output
Image bit depth:16-bit integer
Overwrite existing files without warning?:Yes
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
15 changes: 15 additions & 0 deletions 1.cellprofiler_ic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Perform illumination correction and save corrected images
jenna-tomkinson marked this conversation as resolved.
Show resolved Hide resolved

In this module, we perform illumination correction (IC) on the images for each plate and save the corrected images into new folders.
jenna-tomkinson marked this conversation as resolved.
Show resolved Hide resolved
The images are saved as 16-bit depth, which is the same as the raw data.
jenna-tomkinson marked this conversation as resolved.
Show resolved Hide resolved

## Run the `nf1_ic` notebook

To calculate and apply an IC function on each channel, run the [nf1_ic.ipynb](dnf1_ic.ipynb) notebook as a python script using the code block below:
jenna-tomkinson marked this conversation as resolved.
Show resolved Hide resolved

```bash
# Run this script in terminal
conda activate nf1_cellpainting_data
cd 0.cellprofiler_ic
jenna-tomkinson marked this conversation as resolved.
Show resolved Hide resolved
bash nf1_ic.sh
```
Loading