Skip to content

Commit 9c366bf

Browse files
authored
fix tests related to json pipeline loading (#69)
1 parent dc6f3de commit 9c366bf

2 files changed

Lines changed: 294 additions & 4 deletions

File tree

Lines changed: 281 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
CellProfiler Pipeline: http://www.cellprofiler.org
2+
Version:5
3+
DateRevision:400
4+
GitHash:
5+
ModuleCount:16
6+
HasImagePlaneDetails:False
7+
8+
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]
9+
:
10+
Filter images?:Images only
11+
Select the rule criteria:and (extension does isimage) (directory doesnot containregexp "[\\\\\\\\/]\\\\.")
12+
13+
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]
14+
Extract metadata?:No
15+
Metadata data type:Text
16+
Metadata types:{}
17+
Extraction method count:1
18+
Metadata extraction method:Extract from image file headers
19+
Metadata source:File name
20+
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])
21+
Regular expression to extract from folder name:(?P<Date>[0-9]{4}_[0-9]{2}_[0-9]{2})$
22+
Extract metadata from:All images
23+
Select the filtering criteria:and (file does contain "")
24+
Metadata file location:Elsewhere...|
25+
Match file and image metadata:[]
26+
Use case insensitive matching?:No
27+
Metadata file name:
28+
Does cached metadata exist?:No
29+
30+
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]
31+
Assign a name to:Images matching rules
32+
Select the image type:Grayscale image
33+
Name to assign these images:DNA
34+
Match metadata:[]
35+
Image set matching method:Order
36+
Set intensity range from:Image metadata
37+
Assignments count:3
38+
Single images count:0
39+
Maximum intensity:255.0
40+
Process as 3D?:No
41+
Relative pixel spacing in X:1.0
42+
Relative pixel spacing in Y:1.0
43+
Relative pixel spacing in Z:1.0
44+
Select the rule criteria:and (file does contain "D.TIF")
45+
Name to assign these images:OrigBlue
46+
Name to assign these objects:Cell
47+
Select the image type:Grayscale image
48+
Set intensity range from:Image metadata
49+
Maximum intensity:255.0
50+
Select the rule criteria:and (file does contain "F.TIF")
51+
Name to assign these images:OrigGreen
52+
Name to assign these objects:Nucleus
53+
Select the image type:Grayscale image
54+
Set intensity range from:Image metadata
55+
Maximum intensity:255.0
56+
Select the rule criteria:and (file does contain "R.TIF")
57+
Name to assign these images:OrigRed
58+
Name to assign these objects:Cytoplasm
59+
Select the image type:Grayscale image
60+
Set intensity range from:Image metadata
61+
Maximum intensity:255.0
62+
63+
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]
64+
Do you want to group your images?:No
65+
grouping metadata count:1
66+
Metadata category:None
67+
68+
Crop:[module_num:5|svn_version:'Unknown'|variable_revision_number:3|show_window:True|notes:['Crop the DAPI image down to a 200 x 200 rectangle by entering specific coordinates.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
69+
Select the input image:OrigBlue
70+
Name the output image:CropBlue
71+
Select the cropping shape:Rectangle
72+
Select the cropping method:Coordinates
73+
Apply which cycle's cropping pattern?:First
74+
Left and right rectangle positions:501,700
75+
Top and bottom rectangle positions:251,450
76+
Coordinates of ellipse center:200,500
77+
Ellipse radius, X direction:400
78+
Ellipse radius, Y direction:200
79+
Remove empty rows and columns?:Edges
80+
Select the masking image:None
81+
Select the image with a cropping mask:None
82+
Select the objects:None
83+
84+
Crop:[module_num:6|svn_version:'Unknown'|variable_revision_number:3|show_window:True|notes:['Use the same cropping from the DAPI image for FITC image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
85+
Select the input image:OrigGreen
86+
Name the output image:CropGreen
87+
Select the cropping shape:Previous cropping
88+
Select the cropping method:Coordinates
89+
Apply which cycle's cropping pattern?:First
90+
Left and right rectangle positions:300,600
91+
Top and bottom rectangle positions:300,600
92+
Coordinates of ellipse center:500,500
93+
Ellipse radius, X direction:400
94+
Ellipse radius, Y direction:200
95+
Remove empty rows and columns?:Edges
96+
Select the masking image:None
97+
Select the image with a cropping mask:CropBlue
98+
Select the objects:None
99+
100+
Crop:[module_num:7|svn_version:'Unknown'|variable_revision_number:3|show_window:True|notes:['Use the same cropping from the DAPI image for the rhodamine image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
101+
Select the input image:OrigRed
102+
Name the output image:CropRed
103+
Select the cropping shape:Previous cropping
104+
Select the cropping method:Coordinates
105+
Apply which cycle's cropping pattern?:First
106+
Left and right rectangle positions:300,600
107+
Top and bottom rectangle positions:300,600
108+
Coordinates of ellipse center:500,500
109+
Ellipse radius, X direction:400
110+
Ellipse radius, Y direction:200
111+
Remove empty rows and columns?:Edges
112+
Select the masking image:None
113+
Select the image with a cropping mask:CropBlue
114+
Select the objects:None
115+
116+
IdentifyPrimaryObjects:[module_num:8|svn_version:'Unknown'|variable_revision_number:14|show_window:True|notes:['Identify the nuclei from the DAPI image. Three-class thresholding performs better than the default two-class thresholding in this case.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
117+
Select the input image:CropBlue
118+
Name the primary objects to be identified:Nuclei
119+
Typical diameter of objects, in pixel units (Min,Max):10,40
120+
Discard objects outside the diameter range?:Yes
121+
Discard objects touching the border of the image?:Yes
122+
Method to distinguish clumped objects:Shape
123+
Method to draw dividing lines between clumped objects:Shape
124+
Size of smoothing filter:10
125+
Suppress local maxima that are closer than this minimum allowed distance:5
126+
Speed up by using lower-resolution image to find local maxima?:Yes
127+
Fill holes in identified objects?:After declumping only
128+
Automatically calculate size of smoothing filter for declumping?:Yes
129+
Automatically calculate minimum allowed distance between local maxima?:Yes
130+
Handling of objects if excessive number of objects identified:Continue
131+
Maximum number of objects:500
132+
Display accepted local maxima?:No
133+
Select maxima color:Blue
134+
Use advanced settings?:Yes
135+
Threshold setting version:11
136+
Threshold strategy:Global
137+
Thresholding method:Minimum Cross-Entropy
138+
Threshold smoothing scale:1.3488
139+
Threshold correction factor:1
140+
Lower and upper bounds on threshold:0,1
141+
Manual threshold:0.0
142+
Select the measurement to threshold with:None
143+
Two-class or three-class thresholding?:Three classes
144+
Assign pixels in the middle intensity class to the foreground or the background?:Background
145+
Size of adaptive window:10
146+
Lower outlier fraction:0.05
147+
Upper outlier fraction:0.05
148+
Averaging method:Mean
149+
Variance method:Standard deviation
150+
# of deviations:2
151+
Thresholding method:Otsu
152+
153+
IdentifySecondaryObjects:[module_num:9|svn_version:'Unknown'|variable_revision_number:10|show_window:True|notes:['Identify the cells by using the nuclei as a “seed” region, then growing outwards until stopped by the image threshold or by a neighbor. The Propagation method is used to delineate the boundary between neighboring cells.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
154+
Select the input objects:Nuclei
155+
Name the objects to be identified:Cells
156+
Select the method to identify the secondary objects:Propagation
157+
Select the input image:CropGreen
158+
Number of pixels by which to expand the primary objects:10
159+
Regularization factor:0.05
160+
Discard secondary objects touching the border of the image?:No
161+
Discard the associated primary objects?:No
162+
Name the new primary objects:FilteredNuclei
163+
Fill holes in identified objects?:Yes
164+
Threshold setting version:11
165+
Threshold strategy:Global
166+
Thresholding method:Minimum Cross-Entropy
167+
Threshold smoothing scale:0
168+
Threshold correction factor:1
169+
Lower and upper bounds on threshold:0,1
170+
Manual threshold:0
171+
Select the measurement to threshold with:None
172+
Two-class or three-class thresholding?:Two classes
173+
Assign pixels in the middle intensity class to the foreground or the background?:Foreground
174+
Size of adaptive window:10
175+
Lower outlier fraction:0.05
176+
Upper outlier fraction:0.05
177+
Averaging method:Mean
178+
Variance method:Standard deviation
179+
# of deviations:2
180+
Thresholding method:Otsu
181+
182+
IdentifyTertiaryObjects:[module_num:10|svn_version:'Unknown'|variable_revision_number:3|show_window:True|notes:['Identify the cytoplasm by “subtracting” the nuclei objects from the cell objects.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
183+
Select the larger identified objects:Cells
184+
Select the smaller identified objects:Nuclei
185+
Name the tertiary objects to be identified:Cytoplasm
186+
Shrink smaller object prior to subtraction?:Yes
187+
188+
MeasureObjectSizeShape:[module_num:11|svn_version:'Unknown'|variable_revision_number:3|show_window:True|notes:['Measure morphological features from the cell, nuclei and cytoplasm objects.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
189+
Select object sets to measure:Cells, Nuclei, Cytoplasm
190+
Calculate the Zernike features?:No
191+
Calculate the advanced features?:No
192+
193+
MeasureObjectIntensity:[module_num:12|svn_version:'Unknown'|variable_revision_number:4|show_window:True|notes:['Measure intensity features from nuclei and cell objects against the cropped DAPI image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
194+
Select images to measure:CropBlue
195+
Select objects to measure:Nuclei, Cells, Cytoplasm
196+
197+
MeasureTexture:[module_num:13|svn_version:'Unknown'|variable_revision_number:7|show_window:True|notes:['Measure texture features of the nuclei, cells and cytoplasm from the cropped DAPI image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
198+
Select images to measure:CropBlue
199+
Select objects to measure:Cells, Nuclei, Cytoplasm
200+
Enter how many gray levels to measure the texture at:256
201+
Hidden:1
202+
Measure whole images or objects?:Both
203+
Texture scale to measure:3
204+
205+
GrayToColor:[module_num:14|svn_version:'Unknown'|variable_revision_number:4|show_window:True|notes:['Combine the cropped grayscale channels into a color RGB image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
206+
Select a color scheme:RGB
207+
Rescale intensity:No
208+
Select the image to be colored red:CropRed
209+
Select the image to be colored green:CropGreen
210+
Select the image to be colored blue:CropBlue
211+
Name the output image:RGBImage
212+
Relative weight for the red image:1
213+
Relative weight for the green image:1
214+
Relative weight for the blue image:1
215+
Select the image to be colored cyan:None
216+
Select the image to be colored magenta:None
217+
Select the image to be colored yellow:None
218+
Select the image that determines brightness:None
219+
Relative weight for the cyan image:1
220+
Relative weight for the magenta image:1
221+
Relative weight for the yellow image:1
222+
Relative weight for the brightness image:1
223+
Hidden:1
224+
Image name:None
225+
Color:#ff0000
226+
Weight:1.0
227+
228+
SaveImages:[module_num:15|svn_version:'Unknown'|variable_revision_number:15|show_window:True|notes:['Save the color image as an 8-bit TIF, appending the text RBG to the original filename of the DAPI image.']|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
229+
Select the type of image to save:Image
230+
Select the image to save:RGBImage
231+
Select method for constructing file names:Sequential numbers
232+
Select image name for file prefix:OrigBlue
233+
Enter file prefix:CroppedFlyImage
234+
Number of digits:4
235+
Append a suffix to the image file name?:Yes
236+
Text to append to the image name:RGB
237+
Saved file format:tiff
238+
Output file location:Default Output Folder|None
239+
Image bit depth:8-bit integer
240+
Overwrite existing files without warning?:No
241+
When to save:Every cycle
242+
Record the file and path information to the saved image?:No
243+
Create subfolders in the output folder?:No
244+
Base image folder:Default Input Folder
245+
How to save the series:T (Time)
246+
247+
ExportToSpreadsheet:[module_num:16|svn_version:'Unknown'|variable_revision_number:13|show_window:True|notes:["Export any measurements to a comma-delimited file (.csv). The measurements made for the nuclei, cell and cytoplasm objects will be saved to separate .csv files, in addition to the per-image .csv's."]|batch_state:array([], dtype=uint8)|enabled:True|wants_pause:False]
248+
Select the column delimiter:Comma (",")
249+
Add image metadata columns to your object data file?:No
250+
Add image file and folder names to your object data file?:No
251+
Select the measurements to export:No
252+
Calculate the per-image mean values for object measurements?:Yes
253+
Calculate the per-image median values for object measurements?:No
254+
Calculate the per-image standard deviation values for object measurements?:No
255+
Output file location:Default Output Folder|.
256+
Create a GenePattern GCT file?:No
257+
Select source of sample row name:Metadata
258+
Select the image to use as the identifier:None
259+
Select the metadata to use as the identifier:None
260+
Export all measurement types?:No
261+
Press button to select measurements:None|None
262+
Representation of Nan/Inf:NaN
263+
Add a prefix to file names?:No
264+
Filename prefix:MyExpt_
265+
Overwrite existing files without warning?:Yes
266+
Data to export:Image
267+
Combine these object measurements with those of the previous object?:No
268+
File name:Image.csv
269+
Use the object name for the file name?:No
270+
Data to export:Nuclei
271+
Combine these object measurements with those of the previous object?:No
272+
File name:Nuclei.csv
273+
Use the object name for the file name?:No
274+
Data to export:Cells
275+
Combine these object measurements with those of the previous object?:No
276+
File name:Cells.csv
277+
Use the object name for the file name?:No
278+
Data to export:Cytoplasm
279+
Combine these object measurements with those of the previous object?:No
280+
File name:Cytoplasm.csv
281+
Use the object name for the file name?:No

tests/pipeline/test_pipeline.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,8 +559,12 @@ def test_load_json(self):
559559
pipeline_v5 = get_empty_pipeline()
560560
pipeline_v6 = get_empty_pipeline()
561561

562-
v5_pathname = "../../../CellProfiler/cellprofiler/data/examples/ExampleFly/ExampleFly.cppipe"
563-
v6_pathname = "../data/pipeline/v6.json"
562+
v5_pathname = os.path.realpath(
563+
os.path.join(os.path.dirname(__file__), "../data/pipeline/v5_ExampleFly.cppipe")
564+
)
565+
v6_pathname = os.path.realpath(
566+
os.path.join(os.path.dirname(__file__), "../data/pipeline/v6.json")
567+
)
564568

565569
pipeline_v5.load(v5_pathname)
566570
with open(v6_pathname, "r") as fd:
@@ -586,7 +590,10 @@ def test_dump_json(self):
586590
fp.close()
587591

588592
import json
589-
with open("../data/pipeline/images.json", "r") as fd:
593+
with open(os.path.realpath(
594+
os.path.join(os.path.dirname(__file__), "../data/pipeline/images.json")
595+
),
596+
"r") as fd:
590597
pipeline_groundtruth = json.load(fd)
591598
with open(temp_file.name, "r") as fp:
592599
pipeline_v6 = json.load(fp)
@@ -603,7 +610,9 @@ def test_dump_json(self):
603610

604611
def test_load_and_dump_json(self):
605612
pipeline = get_empty_pipeline()
606-
pathname = "../../../CellProfiler/cellprofiler/data/examples/ExampleFly/ExampleFly.cppipe"
613+
pathname = os.path.realpath(
614+
os.path.join(os.path.dirname(__file__), "../data/pipeline/v5_ExampleFly.cppipe")
615+
)
607616
pipeline.load(pathname)
608617

609618
temp_file = tempfile.NamedTemporaryFile(mode="w+b", suffix=".json", delete=False)

0 commit comments

Comments
 (0)