Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions Superbuild/ITKExternal.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ SET(itk_CACHE_ARGS
"-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
"-DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR>"
"-DITK_BUILD_DEFAULT_MODULES:BOOL=OFF"
"-DITKV3_COMPATIBILITY:BOOL=ON"
"-DITKV4_COMPATIBILITY:BOOL=ON"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The combination of settings here is indicative of full update to ITKv4, and minimal update to ITKv5. For future proofing, we should finish migration to ITKv5. That should be done in a new PR. Possibly after allowing a week or so of use to see if there are any immediate bugs/changes caused by this PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turning on removal of legacy code did not require further changes on my machine. I created an alternative PR with full commit history in #382.

"-DITK_LEGACY_REMOVE:BOOL=OFF"
"-DITK_FUTURE_LEGACY_REMOVE:BOOL=OFF"
"-DModule_ITKRegistrationCommon:BOOL=ON"
"-DModule_ITKSmoothing:BOOL=ON"
"-DModule_ITKAnisotropicSmoothing:BOOL=ON"
Expand All @@ -68,12 +70,13 @@ SET(itk_CACHE_ARGS
"-DModule_ITKIOGIPL:BOOL=ON"
"-DModule_IITKIOMeta:BOOL=ON"
"-DModule_ITKIONRRD:BOOL=ON"
"-DModule_ITKDeprecated:BOOL=ON"
"-DModule_ITKDeprecated:BOOL=OFF"
"-DCMAKE_CXX_FLAGS:STATIC=${CMAKE_CXX_FLAGS}"
"-DCMAKE_CXX_FLAGS_DEBUG:STATIC=${CMAKE_CXX_FLAGS_DEBUG}"
"-DCMAKE_C_FLAGS:STATIC=${CMAKE_C_FLAGS}"
"-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD:STATIC=${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD}"
"-DCMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY:STATIC=${CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY}"
"-DHDF5_BUILD_HL_LIB:BOOL=ON"
)

IF(BUILD_MOSAIC_TOOLS)
Expand All @@ -86,12 +89,12 @@ IF(BUILD_MOSAIC_TOOLS)
)
ENDIF()

SET(itk_GIT_TAG "origin/itk-4.13.1")
SET(itk_GIT_TAG "enableH5HL")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just merged the commit from H5HL branch into master, so this should be changed to master until v5.2.0 is tagged.


# If CMake ever allows overriding the checkout command or adding flags,
# git checkout -q will silence message about detached head (harmless).
ExternalProject_Add(ITK_external
GIT_REPOSITORY "https://github.com/CIBC-Internal/itk.git"
GIT_REPOSITORY "https://github.com/InsightSoftwareConsortium/ITK.git"
GIT_TAG ${itk_GIT_TAG}
UPDATE_COMMAND ""
PATCH_COMMAND ""
Expand All @@ -101,6 +104,6 @@ ExternalProject_Add(ITK_external

# hardcoded, since we need this before ITK's configure step
ExternalProject_Get_Property(ITK_external INSTALL_DIR)
SET(ITK_DIR "${INSTALL_DIR}/lib/cmake/ITK-4.13" CACHE PATH "")
SET(ITK_DIR "${INSTALL_DIR}/lib/cmake/ITK-5.2" CACHE PATH "")

MESSAGE(STATUS "ITK_DIR=${ITK_DIR}")
6 changes: 5 additions & 1 deletion src/Application/Clipboard/ClipboardItem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ ClipboardItem::~ClipboardItem()

ClipboardItemHandle ClipboardItem::clone() const
{
ClipboardItem* cpy = new ClipboardItem( this->private_->width_,
ClipboardItem* cpy = new ClipboardItem( this->private_->width_,
this->private_->height_, this->private_->data_type_ );
cpy->private_->buffer_ = this->private_->buffer_;
cpy->private_->provenance_id_ = this->private_->provenance_id_;
Expand Down Expand Up @@ -126,6 +126,10 @@ void ClipboardItem::resize( size_t width, size_t height, Core::DataType data_typ
case Core::DataType::UINT_E:
buffer_size = sizeof( int );
break;
case Core::DataType::LONGLONG_E:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least, this commit should be called Dženan's and Lee's changes. But I prefer you cherry-picking all our commits with their messages (possibly squashing some, but not all commits).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I'm so sorry! I didn't mean to not give credit to Lee! I really appreciate the help. I will cherry pick in the future!

case Core::DataType::ULONGLONG_E:
buffer_size = sizeof( long long );
break;
case Core::DataType::FLOAT_E:
buffer_size = sizeof( float );
break;
Expand Down
74 changes: 40 additions & 34 deletions src/Application/Filters/Actions/ActionCrop.cc
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
/*
For more information, please see: http://software.sci.utah.edu

The MIT License

Copyright (c) 2016 Scientific Computing and Imaging Institute,
University of Utah.


Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
Expand Down Expand Up @@ -90,14 +90,14 @@ class CropAlgo : public LayerFilter
public:

template< class T >
void crop_typed_data( Core::DataBlockHandle src, Core::DataBlockHandle dst,
void crop_typed_data( Core::DataBlockHandle src, Core::DataBlockHandle dst,
LayerHandle dst_layer );

void crop_data_layer( DataLayerHandle input, DataLayerHandle output );
void crop_mask_layer( MaskLayerHandle input, MaskLayerHandle output );

// RUN_FILTER:
// Implementation of run of the Runnable base class, this function is called
// Implementation of run of the Runnable base class, this function is called
// when the thread is launched.
virtual void run_filter();

Expand All @@ -109,11 +109,11 @@ class CropAlgo : public LayerFilter
}

// GET_LAYER_PREFIX:
// This function returns the name of the filter. The latter is prepended to the new layer name,
// when a new layer is generated.
// This function returns the name of the filter. The latter is prepended to the new layer name,
// when a new layer is generated.
virtual std::string get_layer_prefix() const
{
return "Crop";
return "Crop";
}
};

Expand Down Expand Up @@ -184,14 +184,14 @@ void CropAlgo::run_filter()
void CropAlgo::crop_data_layer( DataLayerHandle input, DataLayerHandle output )
{
Core::DataBlockHandle input_datablock = input->get_data_volume()->get_data_block();
Core::DataBlockHandle output_datablock = Core::StdDataBlock::New(
Core::DataBlockHandle output_datablock = Core::StdDataBlock::New(
output->get_grid_transform(), input_datablock->get_data_type() );
if ( !output_datablock )
if ( !output_datablock )
{
this->report_error( "Could not allocate enough memory" );
return;
}

Core::DataBlock::shared_lock_type data_lock( input_datablock->get_mutex() );
switch ( input_datablock->get_data_type() )
{
Expand All @@ -213,6 +213,12 @@ void CropAlgo::crop_data_layer( DataLayerHandle input, DataLayerHandle output )
case Core::DataType::UINT_E:
this->crop_typed_data< unsigned int >( input_datablock, output_datablock, output );
break;
case Core::DataType::LONGLONG_E:
this->crop_typed_data< long long >( input_datablock, output_datablock, output );
break;
case Core::DataType::ULONGLONG_E:
this->crop_typed_data< unsigned long long >( input_datablock, output_datablock, output );
break;
case Core::DataType::FLOAT_E:
this->crop_typed_data< float >( input_datablock, output_datablock, output );
break;
Expand All @@ -229,11 +235,11 @@ void CropAlgo::crop_data_layer( DataLayerHandle input, DataLayerHandle output )
{
// Centering should be preserved for each layer
Core::GridTransform output_grid_transform = output->get_grid_transform();
output_grid_transform.set_originally_node_centered(
output_grid_transform.set_originally_node_centered(
input->get_grid_transform().get_originally_node_centered() );

this->dispatch_insert_data_volume_into_layer( output, Core::DataVolumeHandle(
new Core::DataVolume( output_grid_transform, output_datablock ) ),
new Core::DataVolume( output_grid_transform, output_datablock ) ),
true );
output->update_progress_signal_( 1.0 );
this->dispatch_unlock_layer( output );
Expand All @@ -253,12 +259,12 @@ void CropAlgo::crop_mask_layer( MaskLayerHandle input, MaskLayerHandle output )
Core::MaskDataBlockHandle input_mask = input->get_mask_volume()->get_mask_data_block();
Core::DataBlockHandle output_mask = Core::StdDataBlock::New(
output->get_grid_transform(), Core::DataType::UCHAR_E );
if ( !output_mask )
if ( !output_mask )
{
this->report_error( "Could not allocate enough memory" );
return;
}

Core::MaskDataBlock::shared_lock_type data_lock( input_mask->get_mutex() );
const unsigned char* src_data = input_mask->get_mask_data();
unsigned char* dst_data = reinterpret_cast< unsigned char* >( output_mask->get_data() );
Expand Down Expand Up @@ -338,7 +344,7 @@ bool ActionCrop::validate( Core::ActionContextHandle& context )
context->report_error( "No input layers specified" );
return false;
}

Core::GridTransform grid_trans;
for ( size_t i = 0; i < this->private_->layer_ids_.size(); ++i )
{
Expand All @@ -361,12 +367,12 @@ bool ActionCrop::validate( Core::ActionContextHandle& context )
context->report_error( "Input layers do not belong to the same group" );
return false;
}
// Check for layer availability
if ( !LayerManager::CheckLayerAvailability( this->private_->layer_ids_[ i ],

// Check for layer availability
if ( !LayerManager::CheckLayerAvailability( this->private_->layer_ids_[ i ],
this->private_->replace_, context, this->private_->sandbox_ ) ) return false;
}

const Core::Point& origin = this->private_->origin_;
const Core::Vector& size = this->private_->size_;

Expand Down Expand Up @@ -404,19 +410,19 @@ bool ActionCrop::validate( Core::ActionContextHandle& context )
return false;
}

// Compute the cropped grid transform
Core::Point clamped_origin( this->private_->start_x_,
// Compute the cropped grid transform
Core::Point clamped_origin( this->private_->start_x_,
this->private_->start_y_, this->private_->start_z_ );
clamped_origin = trans * clamped_origin;
trans( 0, 3 ) = clamped_origin[ 0 ];
trans( 1, 3 ) = clamped_origin[ 1 ];
trans( 2, 3 ) = clamped_origin[ 2 ];
this->private_->output_grid_trans_.load_matrix( trans );
this->private_->output_grid_trans_.set_nx( static_cast< size_t >(
this->private_->output_grid_trans_.set_nx( static_cast< size_t >(
this->private_->end_x_ - this->private_->start_x_ + 1 ) );
this->private_->output_grid_trans_.set_ny( static_cast< size_t >(
this->private_->output_grid_trans_.set_ny( static_cast< size_t >(
this->private_->end_y_ - this->private_->start_y_ + 1 ) );
this->private_->output_grid_trans_.set_nz( static_cast< size_t >(
this->private_->output_grid_trans_.set_nz( static_cast< size_t >(
this->private_->end_z_ - this->private_->start_z_ + 1 ) );
this->private_->output_grid_trans_.set_originally_node_centered(
grid_trans.get_originally_node_centered() );
Expand All @@ -425,7 +431,7 @@ bool ActionCrop::validate( Core::ActionContextHandle& context )
return true;
}

bool ActionCrop::run( Core::ActionContextHandle& context,
bool ActionCrop::run( Core::ActionContextHandle& context,
Core::ActionResultHandle& result )
{
// Create algorithm
Expand Down Expand Up @@ -462,7 +468,7 @@ bool ActionCrop::run( Core::ActionContextHandle& context,
switch ( algo->src_layers_[ i ]->get_type() )
{
case Core::VolumeType::DATA_E:
algo->create_and_lock_data_layer( this->private_->output_grid_trans_,
algo->create_and_lock_data_layer( this->private_->output_grid_trans_,
algo->src_layers_[ i ], algo->dst_layers_[ i ] );
break;
case Core::VolumeType::MASK_E:
Expand All @@ -480,7 +486,7 @@ bool ActionCrop::run( Core::ActionContextHandle& context,
}
dst_layer_ids[ i ] = algo->dst_layers_[ i ]->get_layer_id();
}

// Return the ids of the destination layer.
result = Core::ActionResultHandle( new Core::ActionResult( dst_layer_ids ) );
// If the action is run from a script (provenance is a special case of script),
Expand All @@ -500,9 +506,9 @@ bool ActionCrop::run( Core::ActionContextHandle& context,
return true;
}

void ActionCrop::Dispatch( Core::ActionContextHandle context,
const std::vector< std::string >& layer_ids,
const Core::Point& origin,
void ActionCrop::Dispatch( Core::ActionContextHandle context,
const std::vector< std::string >& layer_ids,
const Core::Point& origin,
const Core::Vector& size, bool replace )
{
ActionCrop* action = new ActionCrop;
Expand Down
Loading