Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openbis
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
sispub
openbis
Commits
bc38abc7
Commit
bc38abc7
authored
13 years ago
by
tpylak
Browse files
Options
Downloads
Patches
Plain Diff
LMS-2585 minimal Flex dropbox
SVN: 23440
parent
ba794dd9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
screening/etc/example-dropbox-configuration/opera-flex/minimal-data-set-handler.py
+88
-0
88 additions, 0 deletions
...pbox-configuration/opera-flex/minimal-data-set-handler.py
with
88 additions
and
0 deletions
screening/etc/example-dropbox-configuration/opera-flex/minimal-data-set-handler.py
0 → 100755
+
88
−
0
View file @
bc38abc7
from
ch.systemsx.cisd.openbis.dss.etl.dto.api.v1
import
ImageMetadata
,
SimpleImageDataConfig
,
Location
from
ch.systemsx.cisd.openbis.plugin.screening.shared.api.v1.dto
import
Geometry
from
ch.systemsx.cisd.imagereaders.bioformats
import
FlexHelper
from
ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.utils
import
DropboxUtils
"""
The code needed to import Evotec/PerkinElmer Opera Flex files with images.
"""
class
OperaFlexImageDataSet
(
SimpleImageDataConfig
):
"""
Returns meta-data for each image in the specified image container.
Parameter imagePath: path to the flex container with many images
Parameter imageIdentifiers: identifiers of all images contained in the image file.
"""
def
extractImagesMetadata
(
self
,
imagePath
,
imageIdentifiers
):
tokens
=
[]
self
.
flexHelper
=
FlexHelper
(
incoming
.
getAbsolutePath
()
+
'
/
'
+
imagePath
)
for
image
in
imageIdentifiers
:
token
=
ImageMetadata
()
token
.
well
=
extractWellCode
(
imagePath
)
imageIndex
=
image
.
getTimeSeriesIndex
()
token
.
tileNumber
=
self
.
flexHelper
.
getTileNumber
(
imageIndex
)
token
.
channelCode
=
self
.
flexHelper
.
getChannelCode
(
imageIndex
)
token
.
imageIdentifier
=
image
tokens
.
append
(
token
)
return
tokens
"""
Extracts well code (e.g. C2) from the flex file path.
"""
def
extractWellCode
(
self
,
imagePath
):
basename
=
os
.
path
.
basename
(
imagePath
)
fileName
=
os
.
path
.
splitext
(
basename
)[
0
]
row
=
int
(
fileName
[
0
:
3
])
col
=
int
(
fileName
[
3
:
6
])
well
=
DropboxUtils
.
translateRowNumberIntoLetterCode
(
row
)
+
str
(
col
)
return
well
"""
Calculates the width and height of the matrix of tiles (a.k.a. fields or sides) in the well
using the content of the Flex file. Passed parameters are not used.
Returns:
Geometry
"""
def
getTileGeometry
(
self
,
imageTokens
,
maxTileNumber
):
tileLocations
=
self
.
_getTileLocationsMap
().
values
()
return
DropboxUtils
.
figureGeometry
(
tileLocations
)
"""
For a given tile number and tiles geometry returns (x,y) which describes where the tile is
located on the well.
Uses flex file to find this out.
Parameter tileNumber: number of the tile
Parameter tileGeometry: the geometry of the well matrix
Returns:
Location
"""
def
getTileCoordinates
(
self
,
tileNumber
,
tileGeometry
):
return
self
.
_getTileLocationsMap
().
get
(
tileNumber
)
def
_getTileLocationsMap
(
self
):
tileSpatialPoints
=
self
.
flexHelper
.
getTileCoordinates
()
# a maximal distance between two points so that they are still considered to describe one point
precision
=
1e-7
return
DropboxUtils
.
tryFigureLocations
(
tileSpatialPoints
,
precision
)
if
incoming
.
isDirectory
():
imageDataset
=
OperaFlexImageDataSet
()
imageDataset
.
setRawImageDatasetType
()
# we use BioFormat library to interpret images with .flex extension
imageDataset
.
setImageLibrary
(
"
BioFormats
"
,
"
TiffDelegateReader
"
)
imageDataset
.
setRecognizedImageExtensions
([
"
flex
"
])
# Here one can add more specific configuration code.
# For simplisity we just assume that the plate sample "/MY-SPACE/MY-PLATE" already exists.
imageDataset
.
setPlate
(
"
MY-SPACE
"
,
"
MY-PLATE
"
)
# boilerplate code
tr
=
service
.
transaction
()
dataSetRegistrationDetails
=
factory
.
createImageRegistrationDetails
(
imageDataset
,
incoming
)
dataSet
=
tr
.
createNewDataSet
(
dataSetRegistrationDetails
)
tr
.
moveFile
(
incoming
.
getAbsolutePath
(),
dataSet
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment