2019-09-27 13:47:08 +02:00
|
|
|
import FileLoaderService from './localFileLoaders/fileLoaderService';
|
|
|
|
|
|
|
|
|
|
const processFile = async file => {
|
|
|
|
|
try {
|
|
|
|
|
const fileLoaderService = new FileLoaderService(file);
|
|
|
|
|
const imageId = fileLoaderService.addFile(file);
|
|
|
|
|
const image = await fileLoaderService.loadFile(file, imageId);
|
|
|
|
|
const dataset = await fileLoaderService.getDataset(image, imageId);
|
|
|
|
|
const studies = await fileLoaderService.getStudies(dataset, imageId);
|
|
|
|
|
|
|
|
|
|
return studies;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(
|
|
|
|
|
error.name,
|
|
|
|
|
':Error when trying to load and process local files:',
|
|
|
|
|
error.message
|
2019-07-11 13:49:29 +02:00
|
|
|
);
|
2019-09-27 13:47:08 +02:00
|
|
|
}
|
|
|
|
|
};
|
2019-07-11 13:49:29 +02:00
|
|
|
|
|
|
|
|
export default async function filesToStudies(files) {
|
2019-09-27 13:47:08 +02:00
|
|
|
const processFilesPromises = files.map(processFile);
|
|
|
|
|
const studies = await Promise.all(processFilesPromises);
|
2019-07-11 13:49:29 +02:00
|
|
|
|
2019-09-27 13:47:08 +02:00
|
|
|
return FileLoaderService.groupSeries(studies.flat());
|
2019-07-11 13:49:29 +02:00
|
|
|
}
|