Skip to content

Commit

Permalink
Merge branch 'main' into update_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sameeul authored Jun 11, 2024
2 parents ee98380 + a05206b commit a0906da
Show file tree
Hide file tree
Showing 11 changed files with 384 additions and 204 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ x86/
[Aa][Rr][Mm]/
[Aa][Rr][Mm]64/
bld/
build/
[Bb]in/
[Oo]bj/
[Ll]og/
[Ll]ogs/
build*/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down Expand Up @@ -475,6 +475,7 @@ coverage.xml
.hypothesis/
.pytest_cache/
cover/
tests/data

# Translations
*.mo
Expand Down Expand Up @@ -565,6 +566,5 @@ cython_debug/
# scratch
scratch/

build/
build_man/
venv/
venv/
.DS_Store
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ set(SOURCE
src/cpp/ts_driver/ometiff/metadata.cc
src/cpp/ts_driver/ometiff/driver.cc
src/cpp/interface/interface.cpp
src/cpp/reader/ometiff.cpp
src/cpp/reader/tsreader.cpp
src/cpp/reader/utilities.cpp
)

Expand Down
47 changes: 28 additions & 19 deletions src/cpp/interface/interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
#include <pybind11/stl_bind.h>
#include <pybind11/numpy.h>
#include <tuple>
#include "../reader/ometiff.h"
#include "../reader/tsreader.h"
#include "../reader/sequence.h"
#include "../reader/utilities.h"

namespace py = pybind11;
using bfiocpp::Seq;

Expand Down Expand Up @@ -31,7 +33,7 @@ inline py::array as_pyarray_shared_5d(std::shared_ptr<image_data> seq_ptr, size_
}
}

py::array get_image_data(bfiocpp::OmeTiffReader& tl, const Seq& rows, const Seq& cols, const Seq& layers, const Seq& channels, const Seq& tsteps) {
py::array get_image_data(bfiocpp::TsReaderCPP& tl, const Seq& rows, const Seq& cols, const Seq& layers, const Seq& channels, const Seq& tsteps) {
auto tmp = tl.GetImageData(rows, cols, layers, channels, tsteps);
auto ih = rows.Stop() - rows.Start() + 1;
auto iw = cols.Stop() - cols.Start() + 1;
Expand All @@ -43,7 +45,7 @@ py::array get_image_data(bfiocpp::OmeTiffReader& tl, const Seq& rows, const Seq&
}


py::array get_iterator_requested_tile_data(bfiocpp::OmeTiffReader& tl, std::int64_t t_index,
py::array get_iterator_requested_tile_data(bfiocpp::TsReaderCPP& tl, std::int64_t t_index,
std::int64_t c_index,
std::int64_t z_index,
std::int64_t y_min, std::int64_t y_max,
Expand All @@ -69,42 +71,49 @@ PYBIND11_MODULE(libbfiocpp, m) {
py::class_<Seq, std::shared_ptr<Seq>>(m, "Seq")
.def(py::init<const size_t, const size_t, const size_t>());

py::class_<bfiocpp::OmeTiffReader, std::shared_ptr<bfiocpp::OmeTiffReader>>(m, "OmeTiffReader")
.def(py::init<const std::string &>())
.def("get_image_height", &bfiocpp::OmeTiffReader::GetImageHeight)
.def("get_image_width", &bfiocpp::OmeTiffReader::GetImageWidth)
.def("get_image_depth", &bfiocpp::OmeTiffReader::GetImageDepth)
.def("get_tile_height", &bfiocpp::OmeTiffReader::GetTileHeight)
.def("get_tile_width", &bfiocpp::OmeTiffReader::GetTileWidth)
.def("get_tile_depth", &bfiocpp::OmeTiffReader::GetTileDepth)
.def("get_channel_count", &bfiocpp::OmeTiffReader::GetChannelCount)
.def("get_tstep_count", &bfiocpp::OmeTiffReader::GetTstepCount)
.def("get_ome_xml_metadata", &bfiocpp::OmeTiffReader::GetOmeXml)
py::class_<bfiocpp::TsReaderCPP, std::shared_ptr<bfiocpp::TsReaderCPP>>(m, "TsReaderCPP")
.def(py::init<const std::string &, bfiocpp::FileType, const std::string &>())
.def("get_image_height", &bfiocpp::TsReaderCPP::GetImageHeight)
.def("get_image_width", &bfiocpp::TsReaderCPP::GetImageWidth)
.def("get_image_depth", &bfiocpp::TsReaderCPP::GetImageDepth)
.def("get_tile_height", &bfiocpp::TsReaderCPP::GetTileHeight)
.def("get_tile_width", &bfiocpp::TsReaderCPP::GetTileWidth)
.def("get_tile_depth", &bfiocpp::TsReaderCPP::GetTileDepth)
.def("get_channel_count", &bfiocpp::TsReaderCPP::GetChannelCount)
.def("get_tstep_count", &bfiocpp::TsReaderCPP::GetTstepCount)
.def("get_datatype", &bfiocpp::TsReaderCPP::GetDataType)
.def("get_tile_coordinate",
[](bfiocpp::OmeTiffReader& tl, std::int64_t y_start, std::int64_t x_start, std::int64_t row_stride, std::int64_t col_stride) {
[](bfiocpp::TsReaderCPP& tl, std::int64_t y_start, std::int64_t x_start, std::int64_t row_stride, std::int64_t col_stride) {
auto row_index = static_cast<std::int64_t>(y_start/row_stride);
auto col_index = static_cast<std::int64_t>(x_start/col_stride);
return std::make_tuple(row_index, col_index);
}
)
.def("get_image_data",
[](bfiocpp::OmeTiffReader& tl, const Seq& rows, const Seq& cols, const Seq& layers, const Seq& channels, const Seq& tsteps) {
[](bfiocpp::TsReaderCPP& tl, const Seq& rows, const Seq& cols, const Seq& layers, const Seq& channels, const Seq& tsteps) {
return get_image_data(tl, rows, cols, layers, channels, tsteps);
}, py::return_value_policy::reference)
.def("send_iterator_read_requests",
[](bfiocpp::OmeTiffReader& tl, std::int64_t const tile_height, std::int64_t const tile_width, std::int64_t const row_stride, std::int64_t const col_stride) {
[](bfiocpp::TsReaderCPP& tl, std::int64_t const tile_height, std::int64_t const tile_width, std::int64_t const row_stride, std::int64_t const col_stride) {
tl.SetIterReadRequests(tile_height, tile_width, row_stride, col_stride);
})
.def("get_iterator_requested_tile_data",
[](bfiocpp::OmeTiffReader& tl, std::int64_t t_index,
[](bfiocpp::TsReaderCPP& tl, std::int64_t t_index,
std::int64_t c_index,
std::int64_t z_index,
std::int64_t y_min, std::int64_t y_max,
std::int64_t x_min, std::int64_t x_max) {
return get_iterator_requested_tile_data(tl, t_index, c_index, z_index, y_min, y_max, x_min, x_max);
}, py::return_value_policy::reference)
.def("__iter__", [](bfiocpp::OmeTiffReader& tl){
.def("__iter__", [](bfiocpp::TsReaderCPP& tl){
return py::make_iterator(tl.iter_request_list.begin(), tl.iter_request_list.end());
}, py::keep_alive<0, 1>());


py::enum_<bfiocpp::FileType>(m, "FileType")
.value("OmeTiff", bfiocpp::FileType::OmeTiff)
.value("OmeZarr", bfiocpp::FileType::OmeZarr)
.export_values();

m.def("get_ome_xml", &bfiocpp::GetOmeXml);
}
149 changes: 0 additions & 149 deletions src/cpp/reader/ometiff.cpp

This file was deleted.

Loading

0 comments on commit a0906da

Please sign in to comment.