Skip to content

Commit

Permalink
STYLE: Factor out itkOMEZarrNGFFCommon.h
Browse files Browse the repository at this point in the history
For re-use across ImageIO and TransformIO.

OMEZarrNGFFAxis is renamed to OMEZarrAxis for brevity. Also, what was
previously ambigiously ome-zarr-ngff is now OME-Zarr.
  • Loading branch information
thewtex committed Jul 28, 2024
1 parent 6bb50d2 commit 19e0d13
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 19 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ set(CMAKE_CXX_STANDARD 17)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

project(IOOMEZarrNGFF CXX C ASM_NASM ASM)

set(IOOMEZarrNGFF_LIBRARIES IOOMEZarrNGFF)

if(NOT ITK_SOURCE_DIR)
find_package(ITK 5.0 REQUIRED)
find_package(ITK 5.4 REQUIRED)
list(APPEND CMAKE_MODULE_PATH ${ITK_CMAKE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(ITKModuleExternal)
Expand Down
46 changes: 46 additions & 0 deletions include/itkOMEZarrNGFFCommon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*=========================================================================
*
* Copyright NumFOCUS
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/

#ifndef itkOMEZarrNGFFCommon_h
#define itkOMEZarrNGFFCommon_h
#include "IOOMEZarrNGFFExport.h"


#include <string>

namespace itk
{
/** \class OMEZarrNGFFAxis
*
* \brief Represent an OME-Zarr NGFF axis
*
* Open Microscopy Environment Zarr Next Generation File Format
* specification can be found at https://github.com/ome/ngff
*
* \ingroup IOOMEZarrNGFF
*/
struct IOOMEZarrNGFF_EXPORT OMEZarrAxis
{
std::string name;
std::string type;
std::string unit;
};

} // end namespace itk

#endif // itkOMEZarrNGFFCommon_h
20 changes: 4 additions & 16 deletions include/itkOMEZarrNGFFImageIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,13 @@
#include <fstream>
#include <string>
#include <vector>

#include "itkImageIOBase.h"

#include "itkOMEZarrNGFFCommon.h"

namespace itk
{
/** \class OMEZarrNGFFAxis
*
* \brief Represent an OME-Zarr NGFF axis
*
* Open Microscopy Environment Zarr Next Generation File Format
* specification can be found at https://github.com/ome/ngff
*
* \ingroup IOOMEZarrNGFF
*/
struct IOOMEZarrNGFF_EXPORT OMEZarrNGFFAxis
{
std::string name;
std::string type;
std::string unit;
};

/** \class OMEZarrNGFFImageIO
*
Expand Down Expand Up @@ -73,7 +61,7 @@ class IOOMEZarrNGFF_EXPORT OMEZarrNGFFImageIO : public ImageIOBase

static constexpr unsigned MaximumDimension = 5; // OME-NGFF specifies up to 5D data
static constexpr int INVALID_INDEX = -1; // for specifying enumerated axis slice indices
using AxesCollectionType = std::vector<OMEZarrNGFFAxis>;
using AxesCollectionType = std::vector<OMEZarrAxis>;

/** The different types of ImageIO's can support data of varying
* dimensionality. For example, some file formats are strictly 2D
Expand Down
2 changes: 1 addition & 1 deletion src/itkOMEZarrNGFFImageIO.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ OMEZarrNGFFImageIO::ReadImageInformation()
auto targetIt = m_StoreAxes.rbegin();
for (const auto & axis : json.at("axes"))
{
*targetIt = (OMEZarrNGFFAxis{ axis.at("name"), axis.at("type"), (axis.contains("unit") ? axis.at("unit") : "") });
*targetIt = (OMEZarrAxis{ axis.at("name"), axis.at("type"), (axis.contains("unit") ? axis.at("unit") : "") });
++targetIt;
}
itkAssertOrThrowMacro(targetIt == m_StoreAxes.rend(),
Expand Down
3 changes: 3 additions & 0 deletions wrapping/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
itk_wrap_module(IOOMEZarrNGFF)
set(WRAPPER_SUBMODULE_ORDER
itkOMEZarrNGFFCommon
)
itk_auto_load_submodules()
itk_end_wrap_module()
4 changes: 4 additions & 0 deletions wrapping/itkOMEZarrNGFFCommon.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
set(WRAPPER_AUTO_INCLUDE_HEADERS OFF)
itk_wrap_include("itkOMEZarrNGFFCommon.h")
itk_wrap_simple_class("itk::OMEZarrAxis")
set(WRAPPER_AUTO_INCLUDE_HEADERS ON)

0 comments on commit 19e0d13

Please sign in to comment.