ImFusion C++ SDK 4.5.0
ImFusion::Project Class Reference
Inheritance diagram for ImFusion::Project:

Classes

struct  Settings
struct  SettingsUpdate
class  TypeSpecificData
struct  PixelwiseLabelType
struct  GeometricAnnotationType
struct  Permissions
 Permissions a user has regarding a project. More...
struct  ImportResult
struct  ProjectImportResult

Public Types

enum  ProjectType { NoProjectType = 0 , PixelwiseProject = 1 << 0 , ImagewiseProject = 1 << 1 , GeometricAnnotationsProject = 1 << 4 }
enum class  DataType {
  InvalidDataType = 0 , SingleChannelImages = 1 << 0 , MultiChannelImages = 1 << 1 , SingleChannelVolumes = 1 << 2 ,
  MultiChannelVolumes = 1 << 3 , AnyDataType = SingleChannelImages | MultiChannelImages | SingleChannelVolumes | MultiChannelVolumes
}
enum  Version {
  V0 = 0 , V1 , V2 , V3 ,
  V4 , V5 , V6 , V7 ,
  V8 , V9 , V10 , V11 ,
  V12 , V13 , V14 , V15 ,
  V16 , V17 , V18 , V19 ,
  V20 , V21 , V22 , V23 ,
  VERSION_COUNT
}
enum class  LayersToModify { All , CurrentOnly }
enum  ImportProjectOption {
  ImportNewOnes = 1 << 0 , ForceCopy = 1 << 1 , UpdateExisting = 1 << 2 , CopyLabelData = 1 << 3 ,
  CopyTags = 1 << 4
}
enum  LoadStatus { OK = 0 , INTERRUPTED , NOT_FOUND , NOT_COMPATIBLE }
enum class  FailureAction { Discard , Retry , Export }
using ProjectTypes = Flags<ProjectType>
using DataTypes = Flags<DataType>
using PixelwiseData = TypeSpecificData<PixelwiseLabelType>
using GeometricAnnotationData = TypeSpecificData<GeometricAnnotationType>
using TypeMapping = std::vector<std::optional<size_t>>
using WarningMessage = std::string
using FailureActionAndPath = std::tuple<FailureAction, std::string>
 The additional path to a folder is only used together with Export.

Public Member Functions

 Project (const Project &)=delete
Project & operator= (const Project &)=delete
Utils::Expected< std::pair< std::unique_ptr< Project >, WarningMessage >, std::stringcopyToRemote (const Filesystem::Url &remoteUrl, const std::optional< std::set< QString > > &descriptorIdsToCopy=std::nullopt, std::shared_ptr< Network::AuthorizationProvider > authProvider=nullptr, Progress *progress=nullptr) const
 Copies the current project to a remote server, with or without data.
std::string addDummyDescriptor (std::unique_ptr< DataDescriptor > desc)
ImportResult import (const std::vector< Import::Entry > &entries, bool copyData, LayersToModify layersToModify, Progress *progress)
 Imports the given entries to the project.
ImportResult import (const Import::Entry &entry, bool copyData, SharedImageSet *preloadedImage, std::shared_ptr< Dicom::DatasetCache > dicomCache, Progress *progress)
 Imports a single entry to the project.
bool importLayers (std::vector< SharedImageSet * > layers, LayersToModify layersToModify, Progress *progress=nullptr)
ProjectImportResult importDescriptorsFromProject (const Project &p, Flags< ImportProjectOption > flags, bool dryRun, Progress *progress=nullptr)
bool deleteDescriptors (const std::vector< DataDescriptor * > &descs)
void setCurrentDataSet (std::unique_ptr< DataSet > data)
Utils::Expected< DataSet *, std::stringloadDataSet (DataDescriptor &desc, Progress *progress)
bool unloadCurrentDataSet (Progress *progress)
std::unique_ptr< DataSettakeCurrentDataSet ()
void switchDataSetWithProgress (DataDescriptor &desc, QWidget *parent)
 Switches to another dataset.
void setFailureCallback (std::function< FailureActionAndPath(std::string)> callback)
 Set a callback for failures that require some action from the user.
std::function< FailureActionAndPath(std::string)> failureCallback () const
void generateMissingThumbnails (Progress *progress=nullptr) const
const QString & name () const
const QString & projectPath () const
int projectId () const
 Returns the id of the remote project or -1 for local projects.
int revision () const
ProjectTypes projectType () const
DataTypes dataType () const
const QString & disabledActions () const
const std::vector< TagType > & tagTypes () const
bool supportsInternalDataStorage () const
const std::vector< ExternalDataStorage > & supportedExternalDataStorage () const
std::optional< ExternalDataStoragefindExternalDataStorage (int id) const
const std::vector< std::unique_ptr< DataDescriptor > > & dataDescriptors () const
DataDescriptorfindDescriptorFromID (const QString &identifier) const
DataSetcurrentData () const
Experimentsexperiments ()
bool applySettingsChange (const SettingsUpdate &update)
TagSystemtagSystem ()
const TagSystemtagSystem () const
bool isReadOnly () const
bool isLocal () const
bool isDummy () const
bool isRemote () const
bool supportsExperiments () const
const Permissionspermissions () const
 Permissions of the current user for this project.
const std::stringserverVersion () const
 Version number of the remote server or empty string for local projects.
bool isSupportRemoteIoAlgorithm (const std::string &id) const
 Checks whether the IoAlgorithm id is supported by the server.
bool allowsData2D () const
bool allowsData3D () const
bool allowsDataSingleChannel () const
bool allowsDataMultiChannel () const
bool isDatasetCompatible (const ImageMetadata &meta) const
DatasetLicenseSystemdatasetLicenses ()
const DatasetLicenseSystemdatasetLicenses () const
bool applyNewLayers (ProjectTypes newProjectType, std::vector< std::unique_ptr< PixelwiseData > > pixelwiseLayers, const std::vector< TypeMapping > &pixelwiseTypeMapping, std::vector< std::unique_ptr< GeometricAnnotationData > > geometricAnnotationLayers, const std::vector< TypeMapping > &geometricAnnotationTypeMapping, Progress *progress=nullptr)
bool hasMultipleLayers () const
const PixelwiseData * pixelwise (std::optional< size_t >={}) const
const GeometricAnnotationData * geometricAnnotations (std::optional< size_t >={}) const
const QVector< QRgb > & pixelwiseColorTable (std::optional< size_t > layerIndex={}) const
 Returns the QImage color table for the given pixelwise layer (or the active one).
size_t numberPixelwiseLayers () const
size_t numberGeometricAnnotationLayers () const
void setActivePixelwise (std::optional< size_t >)
void setActiveGeometricAnnotations (std::optional< size_t >)
std::optional< size_t > activePixelwise () const
std::optional< size_t > activeGeometricAnnotations () const
const std::vector< std::unique_ptr< PixelwiseData > > & pixelwiseLayers () const
const std::vector< std::unique_ptr< GeometricAnnotationData > > & geometricAnnotationLayers () const
void configuration (Properties *p) const override
 Serialize the current object configuration into the given Properties object.
void configure (const Properties *p) override
 Configure this object instance by de-serializing the given Properties.
const Network::AuthorizationProviderauthProvider () const
 Provides authorization for a remote project and other web resources.
std::shared_ptr< Network::AuthorizationProviderauthProviderShared () const
int latestRemoteEventTimestamp () const
std::optional< int > queryAndApplyNewerEvents ()
bool applyRemoteEvent (int timestamp, const QJsonObject &jsonEvent)
QString loadInstructions () const
 Loads instructions for this project.
std::vector< std::stringdatasetGroupingHierarchy () const
 Returns the values the project can be grouped by.
void setDatasetGroupingHierarchy (const std::vector< std::string > &grouping)
 Changes the grouping hierarchy.
std::vector< std::stringdatasetGroupingHierachy () const
void setDatasetGroupingHierachy (const std::vector< std::string > &grouping)
Public Member Functions inherited from ImFusion::SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
Public Member Functions inherited from ImFusion::Configurable
virtual void configureDefaults ()
 Retrieve the properties of this object, replaces values with their defaults and sets it again.
void registerParameter (ParameterBase *param)
 Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration().
void unregisterParameter (const ParameterBase *param)
 Remove the given Parameter or SubProperty from the list of registered parameters.
 Configurable (const Configurable &rhs)
 Configurable (Configurable &&rhs) noexcept
Configurable & operator= (const Configurable &)
Configurable & operator= (Configurable &&) noexcept

Static Public Member Functions

static QJsonObject toJson (Settings settings, const std::vector< TagType > &tagTypes, const std::vector< std::unique_ptr< PixelwiseData > > &pixelwiseLayers, const std::vector< std::unique_ptr< GeometricAnnotationData > > &geometricAnnotationLayers)
 Converts the project parameters to JSON as used by the server.
static std::optional< std::stringfromJson (const QJsonObject &json, Project &project)
 Configures the given project according to the JSON object.
static std::unique_ptr< Project > loadLocalProject (QString projectDir, const Properties &prop, bool readOnly)
 all the static functions below may throw if the data passed is invalid, with a human-readable exception message
static std::unique_ptr< Project > loadRemoteProject (const std::string &projectUrl, std::shared_ptr< Network::AuthorizationProvider > authProvider, Progress *progress=nullptr)
static std::unique_ptr< Project > createNewRemoteProject (Settings settings, const std::vector< TagType > &tagTypes, const std::vector< std::unique_ptr< PixelwiseData > > &pixelwiseLayers, const std::vector< std::unique_ptr< GeometricAnnotationData > > &geometricAnnotationLayers, std::shared_ptr< Network::AuthorizationProvider > authProvider, Progress *progress)
static std::unique_ptr< Project > createNewLocalProject (Settings settings, std::vector< std::unique_ptr< PixelwiseData > > pixelwiseLayers, std::vector< std::unique_ptr< GeometricAnnotationData > > geometricAnnotationLayers)
static std::unique_ptr< Project > dummyProject (ProjectTypes t, std::vector< std::unique_ptr< PixelwiseData > > pixelwiseLayers, std::vector< std::unique_ptr< GeometricAnnotationData > > geometricAnnotationLayers)
static std::unique_ptr< Project > dummyProject (const QJsonObject &config)
static std::unique_ptr< Project > dummyProject (const Properties &projectDB)
static bool isDatasetCompatible (const DataTypes &types, const ImageMetadata &meta)
static bool isRemoteProjectPath (const QString &projectPath)

Public Attributes

Signal descriptorsAdded
Signal< DataDescriptor * > descriptorModified
Signal descriptorOwningStateChanged
Signal< const DataDescriptor * > descriptorDeletedPre
Signal descriptorsDeleted
Signal< const DataDescriptor * > descriptorThumbnailChanged
Signal< const DataDescriptor *, const QString & > descriptorAnnotationThumbnailChanged
Signal< DataSet & > dataUnloadedPre
Signal< const DataDescriptor & > dataLoadedPre
Signal< DataSet & > dataLoadedPost
Signal< SharedImageSet &, Progress * > imageLoadedPost
Signal nameChanged
Signal< const QString &, const QString & > directoryChanged
Signal tagsChangedPre
Signal tagsChangedPost
Signal layersChangedPre
Signal layersChangedPost
Signal anyActiveLayerChangedPre
Signal anyActiveLayerChangedPost
Signal< const PixelwiseData * > activePixelwiseLayerChanged
Signal< const GeometricAnnotationData * > activeAnnotationLayerChanged
Signal< std::stringunhandledRemoteEvent
Public Attributes inherited from ImFusion::Configurable
Signal signalParametersChanged
 Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted.

Static Public Attributes

static const std::string LoadInterrupted

Additional Inherited Members

Protected Member Functions inherited from ImFusion::SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
Protected Attributes inherited from ImFusion::Configurable
std::vector< Paramm_params
 List of all registered Parameter and SubProperty instances.

Member Enumeration Documentation

◆ FailureAction

Enumerator
Discard 

Don't save and potentially discard all changes (does not actively resets the changes, but just ignores the failing save).

Retry 

Try saving again with same settings.

Export 

Export all layers to an external file and discard the changes.

Member Function Documentation

◆ toJson()

QJsonObject ImFusion::Project::toJson ( Settings settings,
const std::vector< TagType > & tagTypes,
const std::vector< std::unique_ptr< PixelwiseData > > & pixelwiseLayers,
const std::vector< std::unique_ptr< GeometricAnnotationData > > & geometricAnnotationLayers )
static

Converts the project parameters to JSON as used by the server.

If this is a new project, Settings.m_projectPath should be empty and all ids should be -1. New tags, layers or labels should also use ids of -1 when editing an existing project.

◆ fromJson()

std::optional< std::string > ImFusion::Project::fromJson ( const QJsonObject & json,
Project & project )
static

Configures the given project according to the JSON object.

This assumes that the project is empty and doesn't have any layers or tags yet. Returns an error message on failure. In case of an error the project might be only half configured and it's probably not a good idea to use it afterwards.

◆ copyToRemote()

Utils::Expected< std::pair< std::unique_ptr< Project >, WarningMessage >, std::string > ImFusion::Project::copyToRemote ( const Filesystem::Url & remoteUrl,
const std::optional< std::set< QString > > & descriptorIdsToCopy = std::nullopt,
std::shared_ptr< Network::AuthorizationProvider > authProvider = nullptr,
Progress * progress = nullptr ) const

Copies the current project to a remote server, with or without data.

The current project can be local or remote. \remoteUrl URL of the remote labels server. \descriptorIdsToCopy selector for which datasets to upload:

  • std::nullopt (default): copy all datasets
  • empty set: copy the project skeleton only (no datasets uploaded)
  • non-empty set: copy only the listed descriptor ids \authProvider authorization provider for the remote server (nullptr (default) triggers an interactive login dialog).

◆ import() [1/2]

ImportResult ImFusion::Project::import ( const std::vector< Import::Entry > & entries,
bool copyData,
LayersToModify layersToModify,
Progress * progress )

Imports the given entries to the project.

copyData specifies whether the datasets should be copied to the project folder or not. If the entries contain labelmaps, they are imported after the regular datasets (see importLayers for details). The ImportResult object contains info about datasets that could be loaded, those that could not be loaded (and the error message associated)

◆ import() [2/2]

ImportResult ImFusion::Project::import ( const Import::Entry & entry,
bool copyData,
SharedImageSet * preloadedImage,
std::shared_ptr< Dicom::DatasetCache > dicomCache,
Progress * progress )

Imports a single entry to the project.

This might result in multiple descriptors if the entry loads as multiple SharedImageSet. copyData specifies if the loaded entry will be stored in the project directory for local projecs. The image will be saved automatically to the project folder when necessary. For remote projects copyData specifies whether the loaded entry will be converted to ImFusionFile before uploading.

A thumbnail for the image is generated automatically.

When copyData is true, a preloadedImage can be passed that will be used instead of loading an image from entry path. preloadedImage can only be used with copyData=true to avoid inconsistencies. If preloadedImage is not the image of entry.m_path or if it was modified after loading, adding it copyData=false would use the wrong metadata and thumbnail. The windowing and data components of preloadedImage might get modified by this method.

◆ switchDataSetWithProgress()

void ImFusion::Project::switchDataSetWithProgress ( DataDescriptor & desc,
QWidget * parent )

Switches to another dataset.

If there is a currentData, it is saved before loadDataSet is called. This method creates a progress dialog and will show a message box if an error occures. It must therefore only be called from UI code. Use loadDataSet otherwise.

◆ setFailureCallback()

void ImFusion::Project::setFailureCallback ( std::function< FailureActionAndPath(std::string)> callback)

Set a callback for failures that require some action from the user.

The callback receives a string containing a description of the error. The callback should decide on an action (e.g. with a dialog) and return the result. The callback might be called multiple times (e.g. retrying multiple times).

◆ permissions()

const Permissions & ImFusion::Project::permissions ( ) const
inline

Permissions of the current user for this project.

For local projects, all permissions are always true.

◆ isSupportRemoteIoAlgorithm()

bool ImFusion::Project::isSupportRemoteIoAlgorithm ( const std::string & id) const

Checks whether the IoAlgorithm id is supported by the server.

The server can optionally restrict the number of supported IoAlgorithm.

◆ pixelwiseColorTable()

const QVector< QRgb > & ImFusion::Project::pixelwiseColorTable ( std::optional< size_t > layerIndex = {}) const

Returns the QImage color table for the given pixelwise layer (or the active one).

The result is lazily computed and cached until the layers change.

◆ configuration()

void ImFusion::Project::configuration ( Properties * p) const
overridevirtual

Serialize the current object configuration into the given Properties object.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configure() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ configure()

void ImFusion::Project::configure ( const Properties * p)
overridevirtual

Configure this object instance by de-serializing the given Properties.

The default implementation will do so automatically for all registered Parameter and SubProperty instances.

See also
configuration() for the inverse functionality

Reimplemented from ImFusion::Configurable.

◆ authProvider()

const Network::AuthorizationProvider & ImFusion::Project::authProvider ( ) const

Provides authorization for a remote project and other web resources.

Also available for local projects, in which case it's only used for datasets that are stored as DICOMweb or another web resource.

◆ loadInstructions()

QString ImFusion::Project::loadInstructions ( ) const

Loads instructions for this project.

For remote projects, instructions are loaded from the server. For local projects, instructions are loaded from an instructions.html in the project directory. Returns an empty string if the project doesn't have any instructions.

◆ datasetGroupingHierarchy()

std::vector< std::string > ImFusion::Project::datasetGroupingHierarchy ( ) const

Returns the values the project can be grouped by.

By default this is "Patient", "Study", "Series". It corresponds to the ImageMetadata::m_grouping field. Each group depends on the previous, e.g. grouping by "Study" will first group by "Patient" and then by "Study" inside each "Patient" group. This property is mainly used to show the grouping options in the UI.

◆ setDatasetGroupingHierarchy()

void ImFusion::Project::setDatasetGroupingHierarchy ( const std::vector< std::string > & grouping)

Changes the grouping hierarchy.

This only changes the hierarchy in the project, but won't change the current grouping in the datasets (because there is no generic way to determine a mapping). There is currently also no signal, because we assume that this is only changed from scripts and not through the Labels UI.

◆ datasetGroupingHierachy()

std::vector< std::string > ImFusion::Project::datasetGroupingHierachy ( ) const
inline
Deprecated
Use datasetGroupingHierarchy() instead.
Deprecated
"Use datasetGroupingHierarchy() instead"

◆ setDatasetGroupingHierachy()

void ImFusion::Project::setDatasetGroupingHierachy ( const std::vector< std::string > & grouping)
inline
Deprecated
Use setDatasetGroupingHierarchy() instead.
Deprecated
"Use setDatasetGroupingHierarchy() instead"

The documentation for this class was generated from the following file:
  • ImFusionLabels/lib/include/ImFusion/Labels/Core/Project.h
Search Tab / S to search, Esc to close