Skip to content

Commit

Permalink
a LoadSpec needs to know if it is intended to use an image sequence
Browse files Browse the repository at this point in the history
  • Loading branch information
toloudis committed Aug 4, 2024
1 parent 12aad22 commit 5096e29
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion agave_app/TimelineDockWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ QTimelineWidget::OnTimeChanged(int newTime)
loadSpec.time = newTime;

if (!m_reader) {
m_reader = std::shared_ptr<IFileReader>(FileReader::getReader(loadSpec.filepath));
m_reader = std::shared_ptr<IFileReader>(FileReader::getReader(loadSpec.filepath, loadSpec.isImageSequence));
if (!m_reader) {
LOG_ERROR << "Could not find a reader for file " << loadSpec.filepath;
return;
Expand Down
1 change: 1 addition & 0 deletions agave_app/agaveGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ agaveGui::open(const std::string& file, const Serialize::ViewerState* vs, bool i
LoadDialog* loadDialog = new LoadDialog(file, multiscaledims, sceneToLoad, this);
if (loadDialog->exec() == QDialog::Accepted) {
loadSpec = loadDialog->getLoadSpec();
loadSpec.isImageSequence = isImageSequence;
dims = multiscaledims[loadDialog->getMultiscaleLevelIndex()].getVolumeDimensions();
keepCurrentUISettings = loadDialog->getKeepSettings();
} else {
Expand Down
4 changes: 3 additions & 1 deletion renderlib/IFileReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct MultiscaleDims;
struct LoadSpec
{
std::string filepath;
bool isImageSequence;
// important for zarr multiscale
// (TODO should store multiscale index instead? ...and then find subpath from metadata)
std::string subpath;
Expand All @@ -33,7 +34,8 @@ struct LoadSpec
, miny(0)
, maxy(0)
, minz(0)
, maxz(0)
, maxz(0),
isImageSequence(false)
{
}

Expand Down
5 changes: 3 additions & 2 deletions renderlib/command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ LoadVolumeFromFileCommand::execute(ExecutionContext* c)
struct STAT64_STRUCT buf;
if (STAT64_FUNCTION(m_data.m_path.c_str(), &buf) == 0) {
// TODO load metadata dims first

// TODO can we load time sequences of separate files here?
std::unique_ptr<IFileReader> reader(FileReader::getReader(m_data.m_path));
if (!reader) {
LOG_ERROR << "Could not find a reader for file " << m_data.m_path;
Expand Down Expand Up @@ -563,7 +563,7 @@ SetTimeCommand::execute(ExecutionContext* c)
std::shared_ptr<ImageXYZC> image;
try {

std::unique_ptr<IFileReader> reader(FileReader::getReader(loadSpec.filepath));
std::unique_ptr<IFileReader> reader(FileReader::getReader(loadSpec.filepath, loadSpec.isImageSequence));
if (!reader) {
LOG_ERROR << "Could not find a reader for file " << loadSpec.filepath;
image = nullptr;
Expand Down Expand Up @@ -663,6 +663,7 @@ LoadDataCommand::execute(ExecutionContext* c)
c->m_loadSpec.minz = m_data.m_zmin;
c->m_loadSpec.maxz = m_data.m_zmax;

// TODO can we load time sequences of separate files here?
std::unique_ptr<IFileReader> reader(FileReader::getReader(m_data.m_path));
if (!reader) {
LOG_ERROR << "Could not find a reader for file " << m_data.m_path;
Expand Down
3 changes: 3 additions & 0 deletions renderlib/io/FileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ LoadSpec::toString() const
if (!subpath.empty()) {
stream << " " << subpath;
}
if (isImageSequence) {
stream << " (sequence)";
}
stream << " : scene " << scene << " time " << time;
stream << " : channels [";
for (auto i : channels) {
Expand Down
15 changes: 13 additions & 2 deletions renderlib/io/FileReaderImageSequence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,38 @@ FileReaderImageSequence::FileReaderImageSequence(const std::string& filepath)
{
m_sequence = initializeSequence(filepath);
}

FileReaderImageSequence::~FileReaderImageSequence() {}

std::shared_ptr<ImageXYZC>
FileReaderImageSequence::loadFromFile(const LoadSpec& loadSpec)
{
LoadSpec sequenceSpec = loadSpec;
sequenceSpec.filepath = m_sequence[loadSpec.time];
sequenceSpec.time = 0;
return m_tiffReader->loadFromFile(sequenceSpec);
}

VolumeDimensions
FileReaderImageSequence::loadDimensions(const std::string& filepath, uint32_t scene)
{
return m_tiffReader->loadDimensions(filepath, scene);
VolumeDimensions vd = m_tiffReader->loadDimensions(filepath, scene);
vd.sizeT = m_sequence.size();
return vd;
}

uint32_t
FileReaderImageSequence::loadNumScenes(const std::string& filepath)
{
return m_tiffReader->loadNumScenes(filepath);
}

std::vector<MultiscaleDims>
FileReaderImageSequence::loadMultiscaleDims(const std::string& filepath, uint32_t scene)
{
return m_tiffReader->loadMultiscaleDims(filepath, scene);
std::vector<MultiscaleDims> dims = m_tiffReader->loadMultiscaleDims(filepath, scene);
for (auto& d : dims) {
d.shape[0] = m_sequence.size();
}
return dims;
}

0 comments on commit 5096e29

Please sign in to comment.