Skip to content

Commit 27f6107

Browse files
committed
docs
1 parent b05013f commit 27f6107

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

Documentation/Scripting/Importing.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,38 @@ The available importer implementations are:
104104
### Notes about DICOM support
105105

106106
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`.
107+
108+
# Async import
109+
110+
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.
111+
112+
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:
113+
114+
```csharp
115+
private static async Task DicomImportDirectoryAsync(IEnumerable<string> files)
116+
{
117+
118+
using (ProgressHandler progressHandler = new ProgressHandler(new EditorProgressView()))
119+
{
120+
progressHandler.StartStage(0.2f, "Loading DICOM series");
121+
122+
IImageSequenceImporter importer = ImporterFactory.CreateImageSequenceImporter(ImageSequenceFormat.DICOM);
123+
IEnumerable<IImageSequenceSeries> seriesList = await importer.LoadSeriesAsync(files, new ImageSequenceImportSettings { progressHandler = progressHandler });
124+
125+
progressHandler.EndStage();
126+
progressHandler.StartStage(0.8f);
127+
128+
int seriesIndex = 0, numSeries = seriesList.Count();
129+
foreach (IImageSequenceSeries series in seriesList)
130+
{
131+
progressHandler.StartStage(1.0f / numSeries, $"Importing series {seriesIndex + 1} of {numSeries}");
132+
VolumeDataset dataset = await importer.ImportSeriesAsync(series, new ImageSequenceImportSettings { progressHandler = progressHandler });
133+
progressHandler.EndStage();
134+
}
135+
136+
progressHandler.EndStage();
137+
}
138+
}
139+
```
140+
141+
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 commit comments

Comments
 (0)