-
Notifications
You must be signed in to change notification settings - Fork 3
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
Mph norm workflow #125
Mph norm workflow #125
Changes from all commits
972f9b3
85e6305
3d89a9e
cdd74d4
72d3ec3
4080bd1
12e876c
75c746c
ea1160b
4ac8b66
6592a8a
9f8726a
2c7cb0d
1c387ce
45bb0e3
2e145fe
beb8d3e
d79adc5
314514b
3847322
19fcd50
9eec96c
20cc284
550f630
d1c397f
c0c4781
f0f32e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,10 @@ | |
"id": "e36293c5-aa89-4029-a3fa-e8ea841bb8b5", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sweeps aren't created in their own folder, they're just put into the main /Data folder. So you need to separately identify each FOV from the sweep, which are given the generic names. This was initially what that
We could change it so that it would give a warning when an FOV is missing, rather than an error, and then ask people to list the first FOV and last FOV of their sweep and it would find the rest, but at that point it started to feel like the solution was almost as complicated as the problem. Up to you though, it would be an easy change
ngreenwald marked this conversation as resolved.
Show resolved
Hide resolved
ngreenwald marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"metadata": {}, | ||
"source": [ | ||
"There are two parts to this notebook. \n", | ||
"There are three parts to this notebook. \n", | ||
"1. The first part creates the necessary folders that toffy is expecting, and only needs to be run the first time you install it on a new CAC. \n", | ||
"2. The second part updates the co-registration parameters between the slide image (optical image) and the stage coordinates. This needs to be run anytime Ionpath changes the co-registration" | ||
"2. The second part updates the co-registration parameters between the slide image (optical image) and the stage coordinates. This needs to be run anytime Ionpath changes the co-registration\n", | ||
"3. The third part generates a tuning curve to correct for shifts in instrument sensitivity, and only needs to be run once per instrument" | ||
] | ||
}, | ||
{ | ||
|
@@ -37,7 +38,8 @@ | |
"import os\n", | ||
"from sklearn.linear_model import LinearRegression\n", | ||
"\n", | ||
"from toffy import tiling_utils" | ||
"from toffy import tiling_utils, normalize\n", | ||
"from ark.utils import io_utils" | ||
] | ||
}, | ||
{ | ||
|
@@ -55,9 +57,12 @@ | |
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"folders = ['D:\\\\Extracted_Images', 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\run_metrics', 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\watcher_logs',\n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\tiled_run_jsons', 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\autolabeled_tma_jsons', \n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\panel_files']\n", | ||
"folders = ['D:\\\\Extracted_Images', 'D:\\\\Rosetta_Compensated_Images', 'D:\\\\Normalized_Images', \n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\run_metrics', 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\watcher_logs',\n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\tiled_run_jsons', \n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\autolabeled_tma_jsons', \n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\panel_files', 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\normalization_curve', \n", | ||
" 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\mph_files']\n", | ||
"\n", | ||
"for folder in folders:\n", | ||
" if not os.path.exists(folder):\n", | ||
|
@@ -178,6 +183,89 @@ | |
"source": [ | ||
"tiling_utils.save_coreg_params(coreg_params)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "14c82566-d6f5-4096-a249-92fae371ab39", | ||
"metadata": {}, | ||
"source": [ | ||
"## 3. Generate sensitivity tuning curve\n", | ||
"Depending on when an FOV was acquired with respect to the last time the detector was tuned, you will see variable levels of antibody signal. These differences in sensitivity can result in differences in marker intensity, when in fact there is no underlying biological difference in the real signal. In order to correct for this, and ensure that samples which have the same expression levels of a given marker record the same intensity, we need to normalize the images. \n", | ||
"\n", | ||
"The normalization process relies on constructing a tuning curve, which accurately tracks the relationship between increasing detector gain and antibody signal. We can use a detector sweep to figure out this relationship. We can then correct each image to ensure that there are consistent levels of antibody signal. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "b4170c03-1619-479c-99f0-ea03ac13d76b", | ||
"metadata": {}, | ||
"source": [ | ||
"### Identify detector sweep\n", | ||
"The first step is selecting a detector sweep. The goal is for this sweep to cover the range of values most often seen during image acqusition. Therefore, it's best to pick a sweep where the suggested change in voltage following the sweep was less than 50V." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "525de367-672a-416c-9c1a-1cb20a397cda", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# pick a name for the sweep, such as the date it was run\n", | ||
"sweep_name = '20220417_pmma'" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e661bba8-6657-4f9f-ba8b-ebb9eab874bc", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# create a new folder with the sweep name\n", | ||
"normalization_dir = 'C:\\\\Users\\\\Customer.ION\\\\Documents\\\\normalization_curve'\n", | ||
"sweep_path = os.path.join(normalization_dir, sweep_name)\n", | ||
"os.makedirs(sweep_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "9cab012d-9092-4136-b81b-9c8b3a969e15", | ||
"metadata": {}, | ||
"source": [ | ||
"Now, copy all of the FOVs from the sweep into the newly created folder, which can be found in *C:\\\\Users\\\\Customer.ION\\\\Documents\\\\normalization_curve*" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "86941169-09a1-43fe-9299-f9f1ca8766b3", | ||
"metadata": {}, | ||
"source": [ | ||
"### Create tuning curve\n", | ||
"We'll then use these FOVs in order to create the curve" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e7d0aa94-a481-4628-b41a-fa2b74d489d9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# define masses to use\n", | ||
"normalize.create_tuning_function(sweep_path=sweep_path)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "762d6e3b-41d1-4064-9578-2bae599e3f99", | ||
"metadata": {}, | ||
"source": [ | ||
"Your curve should look like the image below. It's okay if your values are a bit different, but the shape of the curve should be qualitatively the same. The curve will be saved in the *sweep_path* folder you defined above\n", | ||
"<div>\n", | ||
" <img src=\"img/tuning_curve.png\" width=\"500\"/>\n", | ||
"</div>\n" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't the sensitivity curve generation go in 4b, since it's only used there? Is the idea that putting this here will encourage people to run a sweep before data aq?
Reply via ReviewNB
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's because it only needs to happen once per instrument, not separately for each run. So having it here means it won't be present in the notebook each time people are normalizing