objectExtract {IFC} | R Documentation |
Object Extraction
Description
Extracts / Decompress objects stored in RIF or CIF Files.
Usage
objectExtract(ifd, param, verbose = FALSE, bypass = FALSE, ...)
Arguments
ifd |
list of sub elements of IFD data information extracted by |
param |
object of class 'IFC_param', containing extraction parameters defined by |
verbose |
whether to display information (use for debugging purpose). Default is |
bypass |
whether to bypass checks on |
... |
Arguments passed on to
|
Details
When a mask is detected, 'add_noise'
, 'full_range'
and 'force_range'
are set to FALSE
and range used will be forced to [0,3]
.
Range of image is controlled by 'Images'
information from supplied 'info'
or as extracted by getInfo
and will be returned as 'channels'
by objectParam
.
In case 'mode'
is not "raw"
, 'channels$xmin
', 'channels$xmax
', 'channels$gamma
' will be used for object extraction by objectExtract
unless any of 'force_range'
or 'full_range'
is TRUE
.
Experimental (as of v0.2.0.501): once returned by objectParam
, those 'channels$xmin
' and 'channels$xmax
' can be manually adjusted to ]0,1[
so as to be used as 'probs'
argument to quantile to allow quantile normalization during object extraction (objectExtract
) afterwards.
Value
A list (for every extracted objects) of list (for every exported channels) depending on 'param$export
' parameter:
-"matrix"
, a matrix when 'param$mode
' is set to "raw"
or "gray"
OR an array when 'param$mode
' is "rgb"
,
-"base64"
, a data-uri string,
-"file"
, an invisible file path corresponding to the location of exported file(s).
Note
'...'
will be used to compute 'param'
only if 'param'
is not provided.
/!\ When 'param'
is not provided, if not any of 'fileName'
, 'info'
can be found in '...'
, then attr(ifd, "fileName_image")
will be used as 'fileName'
input parameter to pass to objectParam
.
Source
For image decompression, Lee Kamentsky's code porting from https://github.com/ome/bioformats/blob/4146b9a1797501f0fec7d6cfe69124959bff96ee/components/formats-bsd/src/loci/formats/in/FlowSightReader.java
cited in https://linkinghub.elsevier.com/retrieve/pii/S1046-2023(16)30291-2
BSD implementations of Bio-Formats readers and writers
Copyright (C) 2005 - 2017 Open Microscopy Environment:
- Board of Regents of the University of Wisconsin-Madison
- Glencoe Software, Inc.
- University of Dundee
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Examples
if(requireNamespace("IFCdata", quietly = TRUE)) {
## use a cif file
file_cif <- system.file("extdata", "example.cif", package = "IFCdata")
cif_offs <- getOffsets(fileName = file_cif, fast = TRUE)
## extract infomation
info <- getInfo(fileName = file_cif, from = "analysis")
## retrieve number of objects stored
nobj <- as.integer(info$objcount)
## randomly subset the offsets of at most 5 "img" objects
sel = sample(0:(nobj-1), min(5, nobj))
sub_offs <- subsetOffsets(cif_offs, objects = sel, image_type = "img")
## read IFDs from these "img" objects
IFDs <- getIFD(fileName = file_cif, offsets = sub_offs)
## extract raw data of these"img" objects to matrix
raw = objectExtract(ifd = IFDs, info = info, mode = "raw",
export = "matrix")
## extract base64 "rgb" colorized version of these "img" objects to base64
b64 = objectExtract(ifd = IFDs, info = info, mode = "rgb",
export = "base64", base64_id = TRUE,
write_to = "example_%o_%c.bmp")
## use DisplayGallery to show the first "img" objects and play with ... extra parameters
## force_range, add_noise, selection, composite, see objectParam
DisplayGallery(info = info, offsets = cif_offs, objects = sel,
base64_id = TRUE, write_to = "example_%o_%c.bmp",
force_range = c(FALSE,TRUE,FALSE,TRUE), add_noise = FALSE,
selection = c(1,2,4,6), composite = "1.7/4.3")
} else {
message(sprintf('Please run `install.packages("IFCdata", repos = "%s", type = "source")` %s',
'https://gitdemont.github.io/IFCdata/',
'to install extra files required to run this example.'))
}