Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mlavik1 committed Jun 3, 2023
1 parent b05013f commit 27f6107
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Documentation/Scripting/Importing.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,38 @@ The available importer implementations are:
### Notes about DICOM support

The SimpleITK-based importer is the recommended way to import DICOM datasets, as it supports JPEG compression. See the [SimpleITK documentation](../SimpleITK/SimpleITK.md) for information about how to enable it. Once enabled, _ImporterFactory.CreateImageSequenceImporter_ will automatically return an importer of type `SimpleITKImageSequenceImporter`.

# Async import

Most of the importers also support asynchronous import. This is very useful for VR/AR applications where you defnitely don't want the import to freeze the whole application for too long.

To do async import, create and run an async Task that calls the `Async` version for the importer factory's import methods. Below is an example:

```csharp
private static async Task DicomImportDirectoryAsync(IEnumerable<string> files)
{

using (ProgressHandler progressHandler = new ProgressHandler(new EditorProgressView()))
{
progressHandler.StartStage(0.2f, "Loading DICOM series");

IImageSequenceImporter importer = ImporterFactory.CreateImageSequenceImporter(ImageSequenceFormat.DICOM);
IEnumerable<IImageSequenceSeries> seriesList = await importer.LoadSeriesAsync(files, new ImageSequenceImportSettings { progressHandler = progressHandler });

progressHandler.EndStage();
progressHandler.StartStage(0.8f);

int seriesIndex = 0, numSeries = seriesList.Count();
foreach (IImageSequenceSeries series in seriesList)
{
progressHandler.StartStage(1.0f / numSeries, $"Importing series {seriesIndex + 1} of {numSeries}");
VolumeDataset dataset = await importer.ImportSeriesAsync(series, new ImageSequenceImportSettings { progressHandler = progressHandler });
progressHandler.EndStage();
}

progressHandler.EndStage();
}
}
```

You can optionally pass in a progress handler, which is used to track the progress of the async import. The `ProgressView` is used to display the progress, either in the Unity Editor or in your own GUI. In the above example we use the `EditorProgressView`, which will show a progress bar in the editor - but you can also create your own.

0 comments on commit 27f6107

Please sign in to comment.