Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Bioimage Analysis
wellPlateReader
Commits
ab714727
Commit
ab714727
authored
Jan 20, 2021
by
danyfel80
Browse files
added new code
parent
f9f0737c
Changes
49
Hide whitespace changes
Inline
Side-by-side
WellPlateReader/src/main/java/plugins/adufour/hcs/WellPlateImporter.java
View file @
ab714727
...
...
@@ -21,6 +21,7 @@ import plugins.adufour.hcs.data.WellPlate;
import
plugins.adufour.hcs.gui.WellPlateViewer
;
import
plugins.adufour.hcs.io.WellPlateReader
;
import
plugins.adufour.hcs.io.WellPlateReader_Opera
;
import
plugins.adufour.hcs.io.WellPlateReader_OperaColumbusNew
;
public
class
WellPlateImporter
extends
PluginActionable
{
private
static
final
Set
<
WellPlateReader
>
availableReaders
=
new
HashSet
<
WellPlateReader
>();
...
...
@@ -36,6 +37,7 @@ public class WellPlateImporter extends PluginActionable {
if
(
importers
.
isEmpty
())
{
// Probably debugging within Eclipse => add one (known) entry manually
importers
.
add
((
Class
<
WellPlateReader
>)
WellPlateReader_Opera
.
class
.
asSubclass
(
WellPlateReader
.
class
));
importers
.
add
((
Class
<
WellPlateReader
>)
WellPlateReader_OperaColumbusNew
.
class
.
asSubclass
(
WellPlateReader
.
class
));
}
// Add available file filters
...
...
@@ -83,7 +85,8 @@ public class WellPlateImporter extends PluginActionable {
try
{
File
selection
=
jfc
.
getSelectedFile
();
CancelableProgressFrame
loadingProgress
=
new
CancelableProgressFrame
(
"Loading plate "
+
selection
.
getName
());
CancelableProgressFrame
loadingProgress
=
new
CancelableProgressFrame
(
"Loading plate "
+
selection
.
getName
());
getPreferencesRoot
().
put
(
"lastUsedDirectory"
,
selection
.
getPath
());
...
...
@@ -106,8 +109,7 @@ public class WellPlateImporter extends PluginActionable {
}
/**
* @param path
* Path to check.
* @param path Path to check.
* @return <code>true</code> if at least one reader accepts the given file
*/
public
static
boolean
isValid
(
File
path
)
{
...
...
@@ -121,11 +123,9 @@ public class WellPlateImporter extends PluginActionable {
}
/**
* Looks for an appropriate readed of the files contained in the provided
* path.
* Looks for an appropriate readed of the files contained in the provided path.
*
* @param file
* Path of the folder containing the files to read.
* @param file Path of the folder containing the files to read.
* @return The appropriate reader for the files.
*/
public
static
WellPlateReader
getReaderFor
(
File
file
)
{
...
...
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IChannel.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.awt.Color
;
public
interface
IChannel
{
long
getId
();
String
getName
();
Color
getColor
();
double
getExcitationWavelength
();
double
getEmissionWavelength
();
IImage
getImage
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IField.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.awt.geom.Point2D
;
import
java.util.Map
;
public
interface
IField
{
long
getId
();
Point2D
getPosition
();
Map
<
Long
,
?
extends
IPlane
>
getPlanes
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IImage.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.awt.Color
;
import
java.util.Date
;
public
interface
IImage
{
public
String
getVersion
();
public
String
getId
();
public
String
getState
();
public
long
getBufferNumber
();
public
String
getUrl
();
public
long
getRow
();
public
long
getColumn
();
public
long
getFieldId
();
public
long
getPlaneId
();
public
long
getTimepointId
();
public
long
getChannelId
();
public
Color
getChannelColor
();
public
String
getChannelType
();
public
String
getAcquisitionType
();
public
double
getResolutionX
();
public
double
getResolutionY
();
public
long
getSizeX
();
public
long
getSizeY
();
public
double
getPositionX
();
public
double
getPositionY
();
public
double
getAbsPositionZ
();
public
double
getPositionZ
();
public
double
getTime
();
public
Date
getDate
();
public
double
getExcitationWavelength
();
public
double
getEmissionWavelength
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IPlane.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.util.Map
;
public
interface
IPlane
{
long
getId
();
double
getPositionZ
();
public
Map
<
Long
,
?
extends
ITimepoint
>
getTimepoints
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IPlate.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.awt.Dimension
;
import
java.util.Map
;
public
interface
IPlate
{
String
getId
();
String
getName
();
String
getType
();
Dimension
getDimension
();
Map
<
Long
,
?
extends
IWell
>
getWells
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/ITimepoint.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.util.Map
;
public
interface
ITimepoint
{
long
getId
();
public
Map
<
Long
,
?
extends
IChannel
>
getChannels
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/IWell.java
0 → 100644
View file @
ab714727
package
plugins.adufour.hcs.data
;
import
java.awt.Point
;
import
java.util.Map
;
public
interface
IWell
{
long
getId
();
Point
getPositionInPlate
();
Map
<
Long
,
?
extends
IField
>
getFields
();
}
WellPlateReader/src/main/java/plugins/adufour/hcs/data/Well.java
View file @
ab714727
...
...
@@ -8,25 +8,57 @@ import java.util.Iterator;
import
java.util.LinkedHashMap
;
import
java.util.Map
;
import
icy.type.dimension.Dimension2D
;
import
icy.util.StringUtil
;
public
class
Well
{
public
enum
Shape
{
Circle
(
new
Ellipse2D
.
Double
()),
Square
(
new
Rectangle2D
.
Double
()),
Rectangle
(
new
Rectangle2D
.
Double
());
public
static
class
Shape
{
public
static
Shape
newCircle
()
{
return
new
Shape
(
new
Ellipse2D
.
Double
(
0
,
0
,
1
,
1
));
}
public
static
Shape
newSquare
()
{
return
new
Shape
(
new
Rectangle2D
.
Double
(
0
,
0
,
1
,
1
));
}
public
static
Shape
newRectangle
()
{
return
new
Shape
(
new
Rectangle2D
.
Double
(
0
,
0
,
2
,
1
));
}
public
final
RectangularShape
wellShape
;
private
Shape
(
RectangularShape
shape
)
{
this
.
wellShape
=
shape
;
// Assign default values in case none are available
shape
.
setFrame
(
0
,
0
,
5000
,
5000
);
}
public
void
setDimension
(
double
width
,
double
height
)
{
wellShape
.
setFrame
(
0
,
0
,
width
,
height
);
}
public
RectangularShape
getShape
()
{
return
wellShape
;
}
public
Dimension2D
getDimension
()
{
return
new
Dimension2D
.
Double
(
wellShape
.
getWidth
(),
wellShape
.
getHeight
());
}
public
static
Shape
valueOf
(
String
shape
)
{
Shape
s
;
switch
(
shape
.
toLowerCase
())
{
case
"circle"
:
s
=
newCircle
();
break
;
case
"square"
:
s
=
newSquare
();
break
;
default
:
// rectangle
s
=
newRectangle
();
break
;
}
return
s
;
}
}
/**
...
...
WellPlateReader/src/main/java/plugins/adufour/hcs/data/WellPlate.java
View file @
ab714727
...
...
@@ -5,207 +5,208 @@ import java.util.Iterator;
import
org.xml.sax.SAXException
;
import
com.drew.imaging.tiff.TiffProcessingException
;
import
icy.sequence.Sequence
;
import
ome.xml.meta.OMEXMLMetadata
;
import
plugins.adufour.hcs.io.WellPlateReader
;
public
class
WellPlate
{
private
final
WellPlateReader
wellPlateReader
;
private
final
OMEXMLMetadata
metadata
;
private
final
Sequence
sequence
;
/**
* Linearized 2D array containing all wells
*/
private
final
Well
[]
wells
;
/**
* @param reader
* the reader that creates this well plate (will be used to load individual fields)
* @param metadata
* the well plate metadata containing the plate layout
* @param shape
* the shape of the wells in this plate
*/
public
WellPlate
(
WellPlateReader
reader
,
OMEXMLMetadata
metadata
,
Well
.
Shape
shape
)
{
this
.
wellPlateReader
=
reader
;
this
.
metadata
=
metadata
;
this
.
sequence
=
new
Sequence
(
metadata
);
// Initialize the wells (even if they contain no image)
int
nbRows
=
getNbRows
();
int
nbCols
=
getNbCols
();
wells
=
new
Well
[
nbRows
*
nbCols
];
for
(
int
row
=
0
;
row
<
nbRows
;
row
++)
for
(
int
col
=
0
;
col
<
nbCols
;
col
++)
wells
[
row
*
nbCols
+
col
]
=
new
Well
(
shape
,
row
,
col
);
}
/**
* @return The number of rows in this well plate
*/
public
int
getNbRows
()
{
return
metadata
.
getPlateRows
(
0
).
getValue
();
}
/**
* @return The number of columns in this well plate
*/
public
int
getNbCols
()
{
return
metadata
.
getPlateColumns
(
0
).
getValue
();
}
public
Well
getWellAt
(
int
row
,
int
col
)
{
return
wells
[
row
*
getNbCols
()
+
col
];
}
public
OMEXMLMetadata
getMetaData
()
{
return
metadata
;
}
@Override
public
String
toString
()
{
String
plateID
=
metadata
.
getPlateID
(
0
);
String
plateType
=
metadata
.
getPlateName
(
0
);
return
plateID
+
" ("
+
plateType
+
")"
;
}
public
Sequence
loadField
(
Field
field
)
throws
IOException
,
SAXException
,
TiffProcessingException
{
wellPlateReader
.
loadField
(
field
,
sequence
);
if
(
field
!=
null
)
sequence
.
setName
(
field
.
getWell
().
getAlphanumericID
());
return
sequence
;
}
/**
* @return A well iterator that automatically skips empty wells
*/
public
Iterator
<
Well
>
wellIterator
()
{
return
wellIterator
(
null
);
}
/**
* @return A well iterator that automatically skips empty wells
* @param filters
* one or more templates (separated by spaces) used to select only a subset of wells,
* e.g.:
* <ul>
* <li><code>"A"</code> will select all wells in row A</li>
* <li><code>"A 03 B12"</code> will select all wells in row A, column 03, and well
* B12</li>
* <li>etc.</li>
* </ul>
*/
public
Iterator
<
Well
>
wellIterator
(
final
String
filters
)
{
return
new
Iterator
<
Well
>()
{
int
currentWellIndex
=
-
1
;
int
nextWellIndex
=
0
;
Well
nextWell
=
null
;
@Override
public
Well
next
()
{
currentWellIndex
=
nextWellIndex
;
return
nextWell
;
}
@Override
public
boolean
hasNext
()
{
for
(
int
newWell
=
currentWellIndex
+
1
;
newWell
<
wells
.
length
;
newWell
++)
{
Well
candidateWell
=
wells
[
newWell
];
if
(
candidateWell
.
isEmpty
())
continue
;
// the well is automatically valid if there are no filters
boolean
isValidWell
=
(
filters
==
null
);
if
(
filters
!=
null
)
{
for
(
String
filter
:
filters
.
split
(
"\\s+"
))
if
(
candidateWell
.
getAlphanumericID
().
contains
(
filter
))
{
isValidWell
=
true
;
break
;
}
}
if
(
isValidWell
)
{
nextWell
=
wells
[
newWell
];
nextWellIndex
=
newWell
;
return
true
;
}
}
return
false
;
}
};
}
/**
* @return A field iterator that automatically skips empty wells
*/
public
Iterator
<
Field
>
fieldIterator
()
{
return
fieldIterator
(
null
);
}
/**
* @return A field iterator that automatically skips empty wells
* @param templates
* one or more templates (separated by spaces) used to select only a subset of wells,
* e.g.:
* <ul>
* <li><code>"A"</code> will select all wells in row A</li>
* <li><code>"A 03 B12"</code> will select all wells in row A, column 03, and well
* B12</li>
* <li>etc.</li>
* </ul>
*/
public
Iterator
<
Field
>
fieldIterator
(
final
String
templates
)
{
return
new
Iterator
<
Field
>()
{
Iterator
<
Well
>
wellIterator
=
wellIterator
(
templates
);
Iterator
<
Field
>
currentFieldIterator
=
null
;
@Override
public
Field
next
()
{
return
currentFieldIterator
.
next
();
}
@Override
public
boolean
hasNext
()
{
// Are there more fields remaining?
if
(
currentFieldIterator
!=
null
&&
currentFieldIterator
.
hasNext
())
return
true
;
// If not, a new well perhaps?
if
(
wellIterator
.
hasNext
())
{
currentFieldIterator
=
wellIterator
.
next
().
fieldIterator
();
return
currentFieldIterator
.
hasNext
();
}
return
false
;
}
};
}
public
class
WellPlate
{
private
final
WellPlateReader
wellPlateReader
;
private
final
OMEXMLMetadata
metadata
;
private
final
Sequence
sequence
;
/**
* Linearized 2D array containing all wells
*/
private
final
Well
[]
wells
;
/**
* @param reader the reader that creates this well plate (will be used to load
* individual fields)
* @param metadata the well plate metadata containing the plate layout
* @param shape the shape of the wells in this plate
*/
public
WellPlate
(
WellPlateReader
reader
,
OMEXMLMetadata
metadata
,
Well
.
Shape
shape
)
{
this
.
wellPlateReader
=
reader
;
this
.
metadata
=
metadata
;
this
.
sequence
=
new
Sequence
(
metadata
);
// Initialize the wells (even if they contain no image)
int
nbRows
=
getNbRows
();
int
nbCols
=
getNbCols
();
wells
=
new
Well
[
nbRows
*
nbCols
];
for
(
int
row
=
0
;
row
<
nbRows
;
row
++)
for
(
int
col
=
0
;
col
<
nbCols
;
col
++)
wells
[
row
*
nbCols
+
col
]
=
new
Well
(
shape
,
row
,
col
);
}
/**
* Builds a well plate considering the metadata and the array of wells (already
* prepared before calling this constructor).
*
* @param reader the reader that creates this well plate (will be used to load
* @param metadata the well plate metadata containing the plate layout
* @param wells The wells contained in the plate. Make sure to use the same
* size as in the metadata.
* @throws IllegalArgumentException If the size of the wells array is not
* equivalent to the size specified in the
* metadata.
*/
public
WellPlate
(
WellPlateReader
reader
,
OMEXMLMetadata
metadata
,
Well
[]
wells
)
{
this
.
wellPlateReader
=
reader
;
this
.
metadata
=
metadata
;
this
.
sequence
=
new
Sequence
(
metadata
);
// Initialize the wells with parameter
int
nbRows
=
getNbRows
();
int
nbCols
=
getNbCols
();
if
(
nbRows
*
nbCols
==
wells
.
length
)
this
.
wells
=
wells
;
else
throw
new
IllegalArgumentException
(
"The size of the wells array ("
+
wells
.
length
+
") is not compatible with the metadata ("
+
nbRows
+
", "
+
nbCols
+
")"
);
}
/**
* @return The number of rows in this well plate
*/
public
int
getNbRows
()
{
return
metadata
.
getPlateRows
(
0
).
getValue
();
}
/**
* @return The number of columns in this well plate
*/
public
int
getNbCols
()
{
return
metadata
.
getPlateColumns
(
0
).
getValue
();
}
public
Well
getWellAt
(
int
row
,
int
col
)
{
return
wells
[
row
*
getNbCols
()
+
col
];
}
public
OMEXMLMetadata
getMetaData
()
{
return
metadata
;
}
@Override
public
String
toString
()
{
String
plateID
=
metadata
.
getPlateID
(
0
);
String
plateType
=
metadata
.
getPlateName
(
0
);
return
plateID
+
" ("
+
plateType
+
")"
;
}
public
Sequence
loadField
(
Field
field
)
throws
IOException
,
SAXException
{
wellPlateReader
.
loadField
(
field
,
sequence
);
if
(
field
!=
null
)
sequence
.
setName
(
field
.
getWell
().
getAlphanumericID
());
return
sequence
;
}
/**
* @return A well iterator that automatically skips empty wells
*/
public
Iterator
<
Well
>
wellIterator
()
{
return
wellIterator
(
null
);
}
/**
* @return A well iterator that automatically skips empty wells
* @param filters one or more templates (separated by spaces) used to select
* only a subset of wells, e.g.:
* <ul>
* <li><code>"A"</code> will select all wells in row A</li>
* <li><code>"A 03 B12"</code> will select all wells in row A,
* column 03, and well B12</li>
* <li>etc.</li>
* </ul>
*/
public
Iterator
<
Well
>
wellIterator
(
final
String
filters
)
{
return
new
Iterator
<
Well
>()
{
int
currentWellIndex
=
-
1
;
int
nextWellIndex
=
0
;
Well
nextWell
=
null
;
@Override
public
Well
next
()
{
currentWellIndex
=
nextWellIndex
;