From 29740f7df45d9a207409e35956374621a8360b82 Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Wed, 3 Nov 2021 09:11:37 -0400 Subject: [PATCH 1/3] Rename Image as Frame --- client/src/django.ts | 4 +- client/src/store/index.ts | 118 ++++++++++---------- client/src/types.ts | 4 +- client/src/views/Dataset.vue | 2 +- miqa/core/admin.py | 10 +- miqa/core/migrations/0018_image_to_frame.py | 73 ++++++++++++ miqa/core/models/__init__.py | 4 +- miqa/core/models/evaluation.py | 4 +- miqa/core/models/{image.py => frame.py} | 6 +- miqa/core/rest/__init__.py | 4 +- miqa/core/rest/{image.py => frame.py} | 28 ++--- miqa/core/rest/project.py | 2 +- miqa/core/rest/scan.py | 6 +- miqa/core/tasks.py | 36 +++--- miqa/core/tests/conftest.py | 4 +- miqa/core/tests/factories.py | 6 +- miqa/core/tests/test_rest.py | 4 +- miqa/urls.py | 4 +- 18 files changed, 196 insertions(+), 123 deletions(-) create mode 100644 miqa/core/migrations/0018_image_to_frame.py rename miqa/core/models/{image.py => frame.py} (87%) rename miqa/core/rest/{image.py => frame.py} (71%) diff --git a/client/src/django.ts b/client/src/django.ts index 078d8301..0688691a 100644 --- a/client/src/django.ts +++ b/client/src/django.ts @@ -93,8 +93,8 @@ const djangoClient = { const { data } = await apiClient.post('/scan-decisions', { scan: scanId, decision, note: comment }); return data; }, - async images(scanId: string) { - const { data } = await apiClient.get('/images', { + async frames(scanId: string) { + const { data } = await apiClient.get('/frames', { params: { scan: scanId }, }); const { results } = data; diff --git a/client/src/store/index.ts b/client/src/store/index.ts index 237fc4c6..a2332ef4 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -70,7 +70,7 @@ function getArrayName(filename) { function getData(id, file, webWorker = null) { return new BluebirdPromise((resolve, reject) => { if (datasetCache.has(id)) { - resolve({ imageData: datasetCache.get(id), webWorker }); + resolve({ frameData: datasetCache.get(id), webWorker }); } else { const fileName = file.name; const io = new FileReader(); @@ -78,16 +78,17 @@ function getData(id, file, webWorker = null) { io.onload = function onLoad() { readImageArrayBuffer(webWorker, io.result, fileName) .then(({ webWorker, image }) => { // eslint-disable-line no-shadow - const imageData = convertItkToVtkImage(image, { + const frameData = convertItkToVtkImage(image, { scalarArrayName: getArrayName(fileName), }); - const dataRange = imageData + const dataRange = frameData .getPointData() .getArray(0) .getRange(); - datasetCache.set(id, { imageData }); + datasetCache.set(id, { frameData }); + // eslint-disable-next-line no-use-before-define expandScanRange(id, dataRange); - resolve({ imageData, webWorker }); + resolve({ frameData, webWorker }); }) .catch((error) => { console.log('Problem reading image array buffer'); @@ -103,24 +104,24 @@ function getData(id, file, webWorker = null) { }); } -function loadFile(imageId) { - if (fileCache.has(imageId)) { - return { imageId, fileP: fileCache.get(imageId) }; +function loadFile(frameId) { + if (fileCache.has(frameId)) { + return { frameId, fileP: fileCache.get(frameId) }; } const p = ReaderFactory.downloadDataset( apiClient, 'nifti.nii.gz', - `/images/${imageId}/download`, + `/frames/${frameId}/download`, ); - fileCache.set(imageId, p); - return { imageId, fileP: p }; + fileCache.set(frameId, p); + return { frameId, fileP: p }; } -function loadFileAndGetData(imageId) { - return loadFile(imageId).fileP.then((file) => getData(imageId, file, savedWorker) - .then(({ webWorker, imageData }) => { +function loadFileAndGetData(frameId) { + return loadFile(frameId).fileP.then((file) => getData(frameId, file, savedWorker) + .then(({ webWorker, frameData }) => { savedWorker = webWorker; - return BluebirdPromise.resolve({ imageData }); + return BluebirdPromise.resolve({ frameData }); }) .catch((error) => { const msg = 'loadFileAndGetData caught error getting data'; @@ -138,24 +139,24 @@ function loadFileAndGetData(imageId) { function poolFunction(webWorker, taskInfo) { return new BluebirdPromise((resolve, reject) => { - const { imageId } = taskInfo; + const { frameId } = taskInfo; let filePromise = null; - if (fileCache.has(imageId)) { - filePromise = fileCache.get(imageId); + if (fileCache.has(frameId)) { + filePromise = fileCache.get(frameId); } else { filePromise = ReaderFactory.downloadDataset( apiClient, 'nifti.nii.gz', - `/images/${imageId}/download`, + `/frames/${frameId}/download`, ); - fileCache.set(imageId, filePromise); + fileCache.set(frameId, filePromise); } filePromise .then((file) => { - resolve(getData(imageId, file, webWorker)); + resolve(getData(frameId, file, webWorker)); }) .catch((err) => { console.log('poolFunction: fileP error of some kind'); @@ -227,7 +228,7 @@ function checkLoadExperiment(oldValue, newValue) { projectId: 1, experimentId: newValue.id, scanId, - imageId: datasetId, + frameId: datasetId, }); }); }); @@ -248,11 +249,11 @@ function getNextDataset(experiments, i, j) { // get first scan in next experiment const nextExperiment = experiments[i + 1]; const nextScan = nextExperiment.scans[0]; - return nextScan.images[0]; + return nextScan.frames[0]; } // get next scan in current experiment const nextScan = scans[j + 1]; - return nextScan.images[0]; + return nextScan.frames[0]; } function expandScanRange(datasetId, dataRange) { @@ -387,13 +388,13 @@ const { state.scanDatasets = {}; state.datasets = {}; }, - setCurrentImageId(state, imageId) { - state.currentDatasetId = imageId; + setCurrentFrameId(state, frameId) { + state.currentDatasetId = frameId; }, - setImage(state, { imageId, image }) { + setFrame(state, { frameId, frame }) { // Replace with a new object to trigger a Vuex update state.datasets = { ...state.datasets }; - state.datasets[imageId] = image; + state.datasets[frameId] = frame; }, setScan(state, { scanId, scan }) { // Replace with a new object to trigger a Vuex update @@ -520,10 +521,9 @@ const { const scan = scans[j]; commit('addExperimentScans', { eid: experiment.id, sid: scan.id }); - // Web datasets == Django images // TODO these requests *can* be run in parallel, or collapsed into one XHR // eslint-disable-next-line no-await-in-loop - const { images } = scan; + const { frames } = scan; commit('setScan', { scanId: scan.id, @@ -532,7 +532,7 @@ const { name: scan.name, experiment: experiment.id, cumulativeRange: [Number.MAX_VALUE, -Number.MAX_VALUE], - numDatasets: images.length, + numDatasets: frames.length, // The experiment.scans.note serialization does not contain note metadata. // Just set notes to [] and let reloadScan set the complete values later. notes: [], @@ -542,26 +542,26 @@ const { const nextScan = getNextDataset(experiments, i, j); - for (let k = 0; k < images.length; k += 1) { - const image = images[k]; - commit('addScanDatasets', { sid: scan.id, id: image.id }); - commit('setImage', { - imageId: image.id, - image: { - ...image, + for (let k = 0; k < frames.length; k += 1) { + const frame = frames[k]; + commit('addScanDatasets', { sid: scan.id, id: frame.id }); + commit('setFrame', { + frameId: frame.id, + frame: { + ...frame, scan: scan.id, experiment: experiment.id, index: k, - previousDataset: k > 0 ? images[k - 1].id : null, - nextDataset: k < images.length - 1 ? images[k + 1].id : null, + previousDataset: k > 0 ? frames[k - 1].id : null, + nextDataset: k < frames.length - 1 ? frames[k + 1].id : null, firstDatasetInPreviousScan: firstInPrev, firstDatasetInNextScan: nextScan ? nextScan.id : null, }, }); } - if (images.length > 0) { - firstInPrev = images[0].id; + if (frames.length > 0) { + firstInPrev = frames[0].id; } else { console.error( `${experiment.name}/${scan.name} has no datasets`, @@ -571,17 +571,17 @@ const { } }, async reloadScan({ commit, getters }) { - const currentImage = getters.currentDataset; - // No need to reload if the image doesn't exist or doesn't exist on the server - if (!currentImage || currentImage.local) { + const currentFrame = getters.currentDataset; + // No need to reload if the frame doesn't exist or doesn't exist on the server + if (!currentFrame || currentFrame.local) { return; } - const scanId = currentImage.scan; + const scanId = currentFrame.scan; if (!scanId) { return; } const scan = await djangoRest.scan(scanId); - const images = await djangoRest.images(scanId); + const frames = await djangoRest.frames(scanId); commit('setScan', { scanId: scan.id, scan: { @@ -589,15 +589,15 @@ const { name: scan.name, experiment: scan.experiment, cumulativeRange: [Number.MAX_VALUE, -Number.MAX_VALUE], - numDatasets: images.length, + numDatasets: frames.length, notes: scan.notes, decisions: scan.decisions, }, }); }, - async setCurrentImage({ commit, dispatch }, imageId) { - commit('setCurrentImageId', imageId); - if (imageId) { + async setCurrentFrame({ commit, dispatch }, frameId) { + commit('setCurrentFrameId', frameId); + if (frameId) { dispatch('reloadScan'); } }, @@ -634,9 +634,9 @@ const { let newProxyManager = false; if (oldScan !== newScan && state.proxyManager) { // If we don't "shrinkProxyManager()" and reinitialize it between - // scans, then we can end up with no image + // scans, then we can end up with no frame // slices displayed, even though we have the data and attempted - // to render it. This may be due to image extents changing between + // to render it. This may be due to frame extents changing between // scans, which is not the case from one timestep of a single scan // to tne next. shrinkProxyManager(state.proxyManager); @@ -662,14 +662,14 @@ const { // This try catch and within logic are mainly for handling data doesn't exist issue try { - let imageData = null; + let frameData = null; if (datasetCache.has(dataset.id)) { - imageData = datasetCache.get(dataset.id).imageData; + frameData = datasetCache.get(dataset.id).frameData; } else { const result = await loadFileAndGetData(dataset.id); - imageData = result.imageData; + frameData = result.frameData; } - sourceProxy.setInputData(imageData); + sourceProxy.setInputData(frameData); if (needPrep || !state.proxyManager.getViews().length) { prepareProxyManager(state.proxyManager); state.vtkViews = state.proxyManager.getViews(); @@ -681,12 +681,12 @@ const { state.vtkViews = state.proxyManager.getViews(); } } catch (err) { - console.log('Caught exception loading next image'); + console.log('Caught exception loading next frame'); console.log(err); state.vtkViews = []; commit('setErrorLoadingDataset', true); } finally { - dispatch('setCurrentImage', dataset.id); + dispatch('setCurrentFrame', dataset.id); commit('setLoadingDataset', false); } diff --git a/client/src/types.ts b/client/src/types.ts index 207a702b..c772f0d0 100644 --- a/client/src/types.ts +++ b/client/src/types.ts @@ -7,7 +7,7 @@ interface User { is_superuser: boolean } -interface Image { +interface Frame { id: string, name: string, } @@ -27,7 +27,7 @@ interface Scan { scan_type: string, experiment: string, decisions: ScanDecision[], - images: Image[], + frames: Frame[], } interface Experiment { diff --git a/client/src/views/Dataset.vue b/client/src/views/Dataset.vue index 1da129d9..be0eb3a7 100644 --- a/client/src/views/Dataset.vue +++ b/client/src/views/Dataset.vue @@ -86,7 +86,7 @@ export default { }, advanceLoop() { if (this.scanning) { - this.updateImage(); + this.updateFrame(); this.nextAnimRequest = window.requestAnimationFrame(this.advanceLoop); } }, diff --git a/miqa/core/admin.py b/miqa/core/admin.py index d4955f31..4959644d 100644 --- a/miqa/core/admin.py +++ b/miqa/core/admin.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from django.contrib import admin -from .models import Evaluation, Experiment, Image, Project, Scan, ScanDecision +from .models import Evaluation, Experiment, Frame, Project, Scan, ScanDecision @admin.register(Experiment) @@ -11,8 +11,8 @@ class ExperimentAdmin(admin.ModelAdmin): search_fields = ('name', 'lock_owner') -@admin.register(Image) -class ImageAdmin(admin.ModelAdmin): +@admin.register(Frame) +class FrameAdmin(admin.ModelAdmin): list_display = ('id', 'created', 'modified', 'scan', 'raw_path', 'frame_number') list_filter = ('created', 'modified') raw_id_fields = ('scan',) @@ -33,8 +33,8 @@ class ScanDecisionAdmin(admin.ModelAdmin): @admin.register(Evaluation) class EvaluationAdmin(admin.ModelAdmin): - list_display = ('id', 'image', 'evaluation_model') - list_filter = ('image', 'evaluation_model') + list_display = ('id', 'frame', 'evaluation_model') + list_filter = ('frame', 'evaluation_model') @admin.register(Project) diff --git a/miqa/core/migrations/0018_image_to_frame.py b/miqa/core/migrations/0018_image_to_frame.py new file mode 100644 index 00000000..24c0f209 --- /dev/null +++ b/miqa/core/migrations/0018_image_to_frame.py @@ -0,0 +1,73 @@ +# Generated by Django 3.2.8 on 2021-11-05 19:29 +import uuid + +from django.db import migrations, models +import django.db.models.deletion +import django_extensions.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0017_remove_site'), + ] + + operations = [ + migrations.CreateModel( + name='Frame', + fields=[ + ( + 'created', + django_extensions.db.fields.CreationDateTimeField( + auto_now_add=True, verbose_name='created' + ), + ), + ( + 'modified', + django_extensions.db.fields.ModificationDateTimeField( + auto_now=True, verbose_name='modified' + ), + ), + ( + 'id', + models.UUIDField( + default=uuid.uuid4, editable=False, primary_key=True, serialize=False + ), + ), + ('raw_path', models.CharField(max_length=500, unique=True)), + ('frame_number', models.IntegerField(default=0)), + ( + 'scan', + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name='frames', + to='core.scan', + ), + ), + ], + options={ + 'ordering': ['scan', 'frame_number'], + }, + ), + migrations.RemoveField( + model_name='evaluation', + name='image', + ), + migrations.DeleteModel( + name='Image', + ), + migrations.AddField( + model_name='evaluation', + name='frame', + field=models.ForeignKey( + default=None, on_delete=django.db.models.deletion.PROTECT, to='core.frame' + ), + preserve_default=False, + ), + migrations.AddIndex( + model_name='frame', + index=models.Index( + fields=['scan', 'frame_number'], name='core_frame_scan_id_ea9adc_idx' + ), + ), + ] diff --git a/miqa/core/models/__init__.py b/miqa/core/models/__init__.py index b02350e7..2a342a60 100644 --- a/miqa/core/models/__init__.py +++ b/miqa/core/models/__init__.py @@ -1,13 +1,13 @@ from .evaluation import Evaluation from .experiment import Experiment -from .image import Image +from .frame import Frame from .project import Project from .scan import Scan from .scan_decision import ScanDecision __all__ = [ 'Experiment', - 'Image', + 'Frame', 'Scan', 'Evaluation', 'Project', diff --git a/miqa/core/models/evaluation.py b/miqa/core/models/evaluation.py index 230ce586..a4609133 100644 --- a/miqa/core/models/evaluation.py +++ b/miqa/core/models/evaluation.py @@ -5,9 +5,9 @@ class Evaluation(models.Model): id = models.UUIDField(primary_key=True, default=uuid4, editable=False) - image = models.ForeignKey('Image', null=False, on_delete=models.CASCADE) + frame = models.ForeignKey('Frame', null=False, on_delete=models.PROTECT) evaluation_model = models.CharField(max_length=50) results = models.JSONField() def __str__(self): - return f'Evaluation for {str(self.image.raw_path)}' + return f'Evaluation for {str(self.frame.raw_path)}' diff --git a/miqa/core/models/image.py b/miqa/core/models/frame.py similarity index 87% rename from miqa/core/models/image.py rename to miqa/core/models/frame.py index 9a51c589..057957b8 100644 --- a/miqa/core/models/image.py +++ b/miqa/core/models/frame.py @@ -13,13 +13,13 @@ from miqa.core.models import Experiment -class Image(TimeStampedModel, models.Model): +class Frame(TimeStampedModel, models.Model): class Meta: indexes = [models.Index(fields=['scan', 'frame_number'])] ordering = ['scan', 'frame_number'] id = models.UUIDField(primary_key=True, default=uuid4, editable=False) - scan = models.ForeignKey('Scan', related_name='images', on_delete=models.CASCADE) + scan = models.ForeignKey('Scan', related_name='frames', on_delete=models.CASCADE) raw_path = models.CharField(max_length=500, blank=False, unique=True) frame_number = models.IntegerField(default=0) @@ -28,7 +28,7 @@ def path(self) -> Path: return Path(self.raw_path) @property - def zarr_path(self: Image) -> Path: + def zarr_path(self: Frame) -> Path: return convert_to_store_path(self.path) @property diff --git a/miqa/core/rest/__init__.py b/miqa/core/rest/__init__.py index ebf3b6cd..5f3670cf 100644 --- a/miqa/core/rest/__init__.py +++ b/miqa/core/rest/__init__.py @@ -1,7 +1,7 @@ from .email import EmailView from .experiment import ExperimentViewSet +from .frame import FrameViewSet from .home import HomePageView -from .image import ImageViewSet from .logout import LogoutView from .project import ProjectViewSet from .scan import ScanViewSet @@ -11,7 +11,7 @@ __all__ = [ 'ExperimentViewSet', 'HomePageView', - 'ImageViewSet', + 'FrameViewSet', 'LogoutView', 'ProjectViewSet', 'ScanViewSet', diff --git a/miqa/core/rest/image.py b/miqa/core/rest/frame.py similarity index 71% rename from miqa/core/rest/image.py rename to miqa/core/rest/frame.py index accdcf0d..e55aa91e 100644 --- a/miqa/core/rest/image.py +++ b/miqa/core/rest/frame.py @@ -8,7 +8,7 @@ from rest_framework.permissions import IsAuthenticated from rest_framework.viewsets import GenericViewSet -from miqa.core.models import Evaluation, Image +from miqa.core.models import Evaluation, Frame from .permissions import UserHoldsExperimentLock @@ -19,47 +19,47 @@ class Meta: fields = ['results', 'evaluation_model'] -class ImageSerializer(serializers.ModelSerializer): +class FrameSerializer(serializers.ModelSerializer): class Meta: - model = Image + model = Frame fields = ['id', 'frame_number', 'auto_evaluation'] - ref_name = 'scan_image' + ref_name = 'scan_frame' auto_evaluation = serializers.SerializerMethodField() - def get_auto_evaluation(self, image_object): + def get_auto_evaluation(self, frame_object): try: - evaluation_object = Evaluation.objects.get(image=image_object) + evaluation_object = Evaluation.objects.get(frame=frame_object) return EvaluationSerializer(evaluation_object).data except Evaluation.DoesNotExist: return None -class ImageViewSet(ListModelMixin, GenericViewSet): +class FrameViewSet(ListModelMixin, GenericViewSet): # This ViewSet read-only right now, so we don't need to select_related back to # the Project for permission checking. - queryset = Image.objects.all() + queryset = Frame.objects.all() filter_backends = [filters.DjangoFilterBackend] filterset_fields = ['scan'] permission_classes = [IsAuthenticated, UserHoldsExperimentLock] - serializer_class = ImageSerializer + serializer_class = FrameSerializer @action(detail=True) def download(self, request, pk=None, **kwargs): - image: Image = self.get_object() - path: Path = image.path + frame: Frame = self.get_object() + path: Path = frame.path if not path.is_file(): return HttpResponseServerError('File no longer exists.') # send client zarr data instead when client is ready - # path: Path = image.zarr_path + # path: Path = frame.zarr_path # if not path.exists(): # return HttpResponseServerError('File no longer exists.') fd = open(path, 'rb') - resp = FileResponse(fd, filename=str(image.frame_number)) - resp['Content-Length'] = image.size + resp = FileResponse(fd, filename=str(frame.frame_number)) + resp['Content-Length'] = frame.size return resp diff --git a/miqa/core/rest/project.py b/miqa/core/rest/project.py index dc9614a1..e839b6cc 100644 --- a/miqa/core/rest/project.py +++ b/miqa/core/rest/project.py @@ -41,7 +41,7 @@ class ProjectViewSet(ReadOnlyModelViewSet): def get_queryset(self): if self.action == 'retrieve': return Project.objects.prefetch_related( - 'experiments__scans__images', 'experiments__scans__decisions' + 'experiments__scans__frames', 'experiments__scans__decisions' ) else: return Project.objects.all() diff --git a/miqa/core/rest/scan.py b/miqa/core/rest/scan.py index b3823b34..3679103b 100644 --- a/miqa/core/rest/scan.py +++ b/miqa/core/rest/scan.py @@ -4,7 +4,7 @@ from rest_framework.viewsets import ReadOnlyModelViewSet from miqa.core.models import Scan -from miqa.core.rest.image import ImageSerializer +from miqa.core.rest.frame import FrameSerializer from miqa.core.rest.permissions import UserHoldsExperimentLock from miqa.core.rest.scan_decision import ScanDecisionSerializer @@ -12,10 +12,10 @@ class ScanSerializer(serializers.ModelSerializer): class Meta: model = Scan - fields = ['id', 'name', 'decisions', 'images', 'scan_type'] + fields = ['id', 'name', 'decisions', 'frames', 'scan_type'] ref_name = 'experiment_scan' - images = ImageSerializer(many=True) + frames = FrameSerializer(many=True) decisions = ScanDecisionSerializer(many=True) diff --git a/miqa/core/tasks.py b/miqa/core/tasks.py index 722b56e9..90809eb1 100644 --- a/miqa/core/tasks.py +++ b/miqa/core/tasks.py @@ -10,35 +10,35 @@ validate_import_dict, ) from miqa.core.conversion.nifti_to_zarr_ngff import nifti_to_zarr_ngff -from miqa.core.models import Evaluation, Experiment, Image, Project, Scan +from miqa.core.models import Evaluation, Experiment, Frame, Project, Scan from miqa.learning.evaluation_models import available_evaluation_models from miqa.learning.nn_inference import evaluate_many @shared_task -def evaluate_data(image_ids, project_id): - images = Image.objects.filter(pk__in=image_ids) +def evaluate_data(frame_ids, project_id): + frames = Frame.objects.filter(pk__in=frame_ids) project = Project.objects.get(id=project_id) - model_to_images_map = {} - for image in images: - eval_model_name = project.evaluation_models[[image.scan.scan_type][0]] - if eval_model_name not in model_to_images_map: - model_to_images_map[eval_model_name] = [] - model_to_images_map[eval_model_name].append(image) + model_to_frames_map = {} + for frame in frames: + eval_model_name = project.evaluation_models[[frame.scan.scan_type][0]] + if eval_model_name not in model_to_frames_map: + model_to_frames_map[eval_model_name] = [] + model_to_frames_map[eval_model_name].append(frame) - for model_name, image_set in model_to_images_map.items(): + for model_name, frame_set in model_to_frames_map.items(): current_model = available_evaluation_models[model_name].load() - results = evaluate_many(current_model, [str(image.raw_path) for image in image_set]) + results = evaluate_many(current_model, [str(frame.raw_path) for frame in frame_set]) Evaluation.objects.bulk_create( [ Evaluation( - image=image, + frame=frame, evaluation_model=model_name, - results=results[str(image.raw_path)], + results=results[str(frame.raw_path)], ) - for image in image_set + for frame in frame_set ] ) @@ -77,7 +77,7 @@ def perform_import(import_dict, project_id): # delete old imports of these projects Experiment.objects.filter( project=project_object - ).delete() # cascades to scans -> images, scan_notes + ).delete() # cascades to scans -> frames, scan_notes for experiment_name, experiment_data in project_data['experiments'].items(): experiment_object = Experiment(name=experiment_name, project=project_object) @@ -90,7 +90,7 @@ def perform_import(import_dict, project_id): new_scans.append(scan_object) for frame_number, frame_data in scan_data['frames'].items(): - frame_object = Image( + frame_object = Frame( frame_number=frame_number, raw_path=frame_data['file_location'], scan=scan_object, @@ -101,7 +101,7 @@ def perform_import(import_dict, project_id): Project.objects.bulk_create(new_projects) Experiment.objects.bulk_create(new_experiments) Scan.objects.bulk_create(new_scans) - Image.objects.bulk_create(new_frames) + Frame.objects.bulk_create(new_frames) evaluate_data.delay([frame.id for frame in new_frames], project.id) @@ -119,7 +119,7 @@ def perform_export(project_id): project_object = Project.objects.get(id=project_id) data = [] - for frame_object in Image.objects.filter(scan__experiment__project=project_object): + for frame_object in Frame.objects.filter(scan__experiment__project=project_object): data.append( [ project_object.name, diff --git a/miqa/core/tests/conftest.py b/miqa/core/tests/conftest.py index 9de94252..b8a5367a 100644 --- a/miqa/core/tests/conftest.py +++ b/miqa/core/tests/conftest.py @@ -7,7 +7,7 @@ from .factories import ( ExperimentFactory, - ImageFactory, + FrameFactory, ProjectFactory, ScanDecisionFactory, ScanFactory, @@ -55,4 +55,4 @@ def generator(): register(ProjectFactory) register(ExperimentFactory) register(ScanFactory) -register(ImageFactory) +register(FrameFactory) diff --git a/miqa/core/tests/factories.py b/miqa/core/tests/factories.py index a98ffbf8..cf4c36b2 100644 --- a/miqa/core/tests/factories.py +++ b/miqa/core/tests/factories.py @@ -1,7 +1,7 @@ from django.contrib.auth.models import User import factory -from miqa.core.models import Experiment, Image, Project, Scan, ScanDecision +from miqa.core.models import Experiment, Frame, Project, Scan, ScanDecision class UserFactory(factory.django.DjangoModelFactory): @@ -56,9 +56,9 @@ class Meta: creator = factory.SubFactory(UserFactory) -class ImageFactory(factory.django.DjangoModelFactory): +class FrameFactory(factory.django.DjangoModelFactory): class Meta: - model = Image + model = Frame id = factory.Faker('uuid4') raw_path = factory.Faker('file_path') diff --git a/miqa/core/tests/test_rest.py b/miqa/core/tests/test_rest.py index 7fb4e4d2..6884c459 100644 --- a/miqa/core/tests/test_rest.py +++ b/miqa/core/tests/test_rest.py @@ -83,8 +83,8 @@ def test_scan_decisions_list(authenticated_api_client, scan_decision): @pytest.mark.django_db -def test_images_list(authenticated_api_client, image): - resp = authenticated_api_client.get('/api/v1/images') +def test_frames_list(authenticated_api_client, frame): + resp = authenticated_api_client.get('/api/v1/frames') assert resp.status_code == 200 assert resp.data['count'] == 1 diff --git a/miqa/urls.py b/miqa/urls.py index 20677600..c4416e31 100644 --- a/miqa/urls.py +++ b/miqa/urls.py @@ -8,8 +8,8 @@ from miqa.core.rest import ( EmailView, ExperimentViewSet, + FrameViewSet, HomePageView, - ImageViewSet, LogoutView, ProjectViewSet, ScanDecisionViewSet, @@ -21,7 +21,7 @@ router.register('projects', ProjectViewSet, basename='project') router.register('experiments', ExperimentViewSet) router.register('scans', ScanViewSet) -router.register('images', ImageViewSet) +router.register('frames', FrameViewSet) router.register('users', UserViewSet) router.register('scan-decisions', ScanDecisionViewSet) From 049c20ace882ea8503c2a3b46f6cf0c3421f963b Mon Sep 17 00:00:00 2001 From: Anne Haley Date: Sat, 6 Nov 2021 11:21:00 -0400 Subject: [PATCH 2/3] rename dataset in frontend to frame --- client/src/components/ControlPanel.vue | 22 +-- client/src/components/EmailDialog.vue | 6 +- client/src/components/ExperimentsView.vue | 10 +- .../src/components/KeyboardShortcutDialog.vue | 4 +- client/src/components/Navbar.vue | 8 +- client/src/components/VtkViewer.vue | 16 +- client/src/router.ts | 8 +- client/src/store/index.ts | 176 +++++++++--------- client/src/utils/ReaderFactory.js | 8 +- client/src/utils/helper.js | 2 +- client/src/views/{Dataset.vue => Frame.vue} | 64 +++---- client/src/vtk/proxyFilter.js | 6 +- client/src/vtk/viewManager.js | 4 +- 13 files changed, 167 insertions(+), 167 deletions(-) rename client/src/views/{Dataset.vue => Frame.vue} (80%) diff --git a/client/src/components/ControlPanel.vue b/client/src/components/ControlPanel.vue index 06ca7d34..30b32515 100644 --- a/client/src/components/ControlPanel.vue +++ b/client/src/components/ControlPanel.vue @@ -10,7 +10,7 @@ import UserAvatar from './UserAvatar.vue'; import ScanDecision from './ScanDecision.vue'; export default { - name: 'Dataset', + name: 'Frame', components: { EvaluationResults, UserAvatar, @@ -31,10 +31,10 @@ export default { ]), ...mapGetters([ 'currentViewData', - 'nextDataset', - 'getDataset', - 'previousDataset', - 'currentDataset', + 'nextFrame', + 'getFrame', + 'previousFrame', + 'currentFrame', ]), ...mapMutations([ 'updateExperiment', @@ -52,7 +52,7 @@ export default { return this.currentViewData.lockOwner; }, representation() { - return this.currentDataset && this.proxyManager.getRepresentations()[0]; + return this.currentFrame && this.proxyManager.getRepresentations()[0]; }, winMin() { return this.representation.getPropertyDomainByName('windowWidth').min; @@ -90,7 +90,7 @@ export default { this.representation.setWindowLevel(value); } }, - currentDataset() { + currentFrame() { this.updateWinLev(); }, experimentId(newValue, oldValue) { @@ -151,11 +151,11 @@ export default { updateImage() { if (this.direction === 'back') { this.$router - .push(this.previousDataset ? this.previousDataset : '') + .push(this.previousFrame ? this.previousFrame : '') .catch(this.handleNavigationError); } else if (this.direction === 'forward') { this.$router - .push(this.nextDataset ? this.nextDataset : '') + .push(this.nextFrame ? this.nextFrame : '') .catch(this.handleNavigationError); } else if (this.direction === 'previous') { this.$router @@ -383,7 +383,7 @@ export default { style="text-align: right" > fa-caret-left store.state.screenshots); - const currentDataset = computed(() => store.getters.currentDataset); + const currentFrame = computed(() => store.getters.currentFrame); const currentScan = computed(() => store.getters.currentScan); const { removeScreenshot } = store.commit; @@ -31,7 +31,7 @@ export default defineComponent({ return { screenshots, - currentDataset, + currentFrame, currentScan, removeScreenshot, user, @@ -59,7 +59,7 @@ export default defineComponent({ this.initialize(); } }, - currentDataset(value) { + currentFrame(value) { if (value) { this.initialize(); } diff --git a/client/src/components/ExperimentsView.vue b/client/src/components/ExperimentsView.vue index cf35ebc1..7858a391 100644 --- a/client/src/components/ExperimentsView.vue +++ b/client/src/components/ExperimentsView.vue @@ -25,8 +25,8 @@ export default { 'experimentScans', 'loadingExperiment', 'scans', - 'scanDatasets', - 'datasets', + 'scanFrames', + 'frames', ]), ...mapGetters(['currentScan', 'currentExperiment']), orderedExperiments() { @@ -53,8 +53,8 @@ export default { }; }); }, - getIdOfFirstDatasetInScan(scanId) { - return `${this.scanDatasets[scanId][0]}`; + getIdOfFirstFrameInScan(scanId) { + return `${this.scanFrames[scanId][0]}`; }, decisionToRating(decisions) { if (decisions.length === 0) return {}; @@ -125,7 +125,7 @@ export default { class="body-1" > ({ shortcuts: [ - ['Next dataset', [['→']]], - ['Previous dataset', [['←']]], + ['Next frame', [['→']]], + ['Previous frame', [['←']]], [ 'Change slices', [ diff --git a/client/src/components/Navbar.vue b/client/src/components/Navbar.vue index 1c0ca9ba..5034ebad 100644 --- a/client/src/components/Navbar.vue +++ b/client/src/components/Navbar.vue @@ -21,7 +21,7 @@ export default defineComponent({ KeyboardShortcutDialog, }, props: { - datasetView: { + frameView: { type: Boolean, default: false, }, @@ -40,7 +40,7 @@ export default defineComponent({ 'screenshots', ]), ...mapGetters([ - 'currentDataset', + 'currentFrame', ]), notes() { if (this.currentScan) { @@ -87,7 +87,7 @@ export default defineComponent({ -
+
keyboard { - if (!this.loadingDataset) { + if (!this.loadingFrame) { this.slice = this.representation.getSlice(); } }); @@ -173,7 +173,7 @@ export default { this.setCurrentScreenshot({ name: `${this.currentScan.experiment}/${ this.currentScan.name - }/${cleanDatasetName(this.currentDataset.name)}/${this.displayName}`, + }/${cleanFrameName(this.currentFrame.name)}/${this.displayName}`, dataURL, }); }, diff --git a/client/src/router.ts b/client/src/router.ts index 411809bb..a0a10afb 100644 --- a/client/src/router.ts +++ b/client/src/router.ts @@ -2,7 +2,7 @@ import Vue from 'vue'; import Router from 'vue-router'; import Projects from './views/Projects.vue'; -import Dataset from './views/Dataset.vue'; +import Frame from './views/Frame.vue'; import Login from './views/Login.vue'; Vue.use(Router); @@ -21,9 +21,9 @@ export default new Router({ }, // Order matters { - path: '/:datasetId?', - name: 'dataset', - component: Dataset, + path: '/:frameId?', + name: 'frame', + component: Frame, }, { path: '*', diff --git a/client/src/store/index.ts b/client/src/store/index.ts index a2332ef4..6065159d 100644 --- a/client/src/store/index.ts +++ b/client/src/store/index.ts @@ -25,7 +25,7 @@ const { convertItkToVtkImage } = ITKHelper; Vue.use(Vuex); const fileCache = new Map(); -const datasetCache = new Map(); +const frameCache = new Map(); let readDataQueue = []; const poolSize = Math.floor(navigator.hardwareConcurrency / 2) || 2; let taskRunId = -1; @@ -69,8 +69,8 @@ function getArrayName(filename) { function getData(id, file, webWorker = null) { return new BluebirdPromise((resolve, reject) => { - if (datasetCache.has(id)) { - resolve({ frameData: datasetCache.get(id), webWorker }); + if (frameCache.has(id)) { + resolve({ frameData: frameCache.get(id), webWorker }); } else { const fileName = file.name; const io = new FileReader(); @@ -85,7 +85,7 @@ function getData(id, file, webWorker = null) { .getPointData() .getArray(0) .getRange(); - datasetCache.set(id, { frameData }); + frameCache.set(id, { frameData }); // eslint-disable-next-line no-use-before-define expandScanRange(id, dataRange); resolve({ frameData, webWorker }); @@ -108,7 +108,7 @@ function loadFile(frameId) { if (fileCache.has(frameId)) { return { frameId, fileP: fileCache.get(frameId) }; } - const p = ReaderFactory.downloadDataset( + const p = ReaderFactory.downloadFrame( apiClient, 'nifti.nii.gz', `/frames/${frameId}/download`, @@ -146,7 +146,7 @@ function poolFunction(webWorker, taskInfo) { if (fileCache.has(frameId)) { filePromise = fileCache.get(frameId); } else { - filePromise = ReaderFactory.downloadDataset( + filePromise = ReaderFactory.downloadFrame( apiClient, 'nifti.nii.gz', `/frames/${frameId}/download`, @@ -197,7 +197,7 @@ function startReaderWorkerPool() { }); } -// cache datasets associated with scans of current experiment +// cache frames associated with scans of current experiment function checkLoadExperiment(oldValue, newValue) { if ( !newValue @@ -210,10 +210,10 @@ function checkLoadExperiment(oldValue, newValue) { if (oldValue) { const oldExperimentScans = store.state.experimentScans[oldValue.id]; oldExperimentScans.forEach((scanId) => { - const scanDatasets = store.state.scanDatasets[scanId]; - scanDatasets.forEach((datasetId) => { - fileCache.delete(datasetId); - datasetCache.delete(datasetId); + const scanFrames = store.state.scanFrames[scanId]; + scanFrames.forEach((frameId) => { + fileCache.delete(frameId); + frameCache.delete(frameId); }); }); } @@ -221,22 +221,22 @@ function checkLoadExperiment(oldValue, newValue) { readDataQueue = []; const newExperimentScans = store.state.experimentScans[newValue.id]; newExperimentScans.forEach((scanId) => { - const scanDatasets = store.state.scanDatasets[scanId]; - scanDatasets.forEach((datasetId) => { + const scanFrames = store.state.scanFrames[scanId]; + scanFrames.forEach((frameId) => { readDataQueue.push({ // TODO don't hardcode projectId projectId: 1, experimentId: newValue.id, scanId, - frameId: datasetId, + frameId, }); }); }); startReaderWorkerPool(); } -// get next scan (across experiments) -function getNextDataset(experiments, i, j) { +// get next frame (across experiments and scans) +function getNextFrame(experiments, i, j) { const experiment = experiments[i]; const { scans } = experiment; @@ -256,9 +256,9 @@ function getNextDataset(experiments, i, j) { return nextScan.frames[0]; } -function expandScanRange(datasetId, dataRange) { - if (datasetId in store.state.datasets) { - const scanId = store.state.datasets[datasetId].scan; +function expandScanRange(frameId, dataRange) { + if (frameId in store.state.frames) { + const scanId = store.state.frames[frameId].scan; const scan = store.state.scans[scanId]; if (dataRange[0] < scan.cumulativeRange[0]) { [scan.cumulativeRange[0]] = dataRange; @@ -276,13 +276,13 @@ const initState = { experiments: {}, experimentScans: {}, scans: {}, - scanDatasets: {}, - datasets: {}, + scanFrames: {}, + frames: {}, proxyManager: null, vtkViews: [], - currentDatasetId: null, - loadingDataset: false, - errorLoadingDataset: false, + currentFrameId: null, + loadingFrame: false, + errorLoadingFrame: false, loadingExperiment: false, currentScreenshot: null, screenshots: [], @@ -314,13 +314,13 @@ const { return state; }, currentViewData(state) { - const currentDataset = state.currentDatasetId ? state.datasets[state.currentDatasetId] : null; - const scan = state.scans[currentDataset.scan]; - const experiment = currentDataset.experiment - ? state.experiments[currentDataset.experiment] : null; + const currentFrame = state.currentFrameId ? state.frames[state.currentFrameId] : null; + const scan = state.scans[currentFrame.scan]; + const experiment = currentFrame.experiment + ? state.experiments[currentFrame.experiment] : null; const project = state.projects.filter((x) => x.id === experiment.project)[0]; const experimentScansList = state.experimentScans[experiment.id]; - const scanFramesList = state.scanDatasets[scan.id]; + const scanFramesList = state.scanFrames[scan.id]; return { projectName: project.name, experimentId: experiment.id, @@ -331,39 +331,39 @@ const { scanName: scan.name, scanDecisions: scan.decisions, scanPositionString: `(${experimentScansList.indexOf(scan.id) + 1}/${experimentScansList.length})`, - framePositionString: `(${scanFramesList.indexOf(currentDataset.id) + 1}/${scanFramesList.length})`, - backTo: currentDataset.previousDataset, - forwardTo: currentDataset.nextDataset, - upTo: currentDataset.firstDatasetInPreviousScan, - downTo: currentDataset.firstDatasetInNextScan, - currentAutoEvaluation: currentDataset.auto_evaluation, + framePositionString: `(${scanFramesList.indexOf(currentFrame.id) + 1}/${scanFramesList.length})`, + backTo: currentFrame.previousFrame, + forwardTo: currentFrame.nextFrame, + upTo: currentFrame.firstFrameInPreviousScan, + downTo: currentFrame.firstFrameInNextScan, + currentAutoEvaluation: currentFrame.auto_evaluation, autoWindow: experiment.autoWindow, autoLevel: experiment.autoLevel, }; }, - currentDataset(state) { - const { datasets, currentDatasetId } = state; - return currentDatasetId ? datasets[currentDatasetId] : null; + currentFrame(state) { + const { frames, currentFrameId } = state; + return currentFrameId ? frames[currentFrameId] : null; }, - previousDataset(state, getters) { - return getters.currentDataset - ? getters.currentDataset.previousDataset + previousFrame(state, getters) { + return getters.currentFrame + ? getters.currentFrame.previousFrame : null; }, - nextDataset(state, getters) { - return getters.currentDataset ? getters.currentDataset.nextDataset : null; + nextFrame(state, getters) { + return getters.currentFrame ? getters.currentFrame.nextFrame : null; }, - getDataset(state) { - return (datasetId) => { - if (!datasetId || !state.datasets[datasetId]) { + getFrame(state) { + return (frameId) => { + if (!frameId || !state.frames[frameId]) { return undefined; } - return state.datasets[datasetId]; + return state.frames[frameId]; }; }, currentScan(state, getters) { - if (getters.currentDataset) { - const curScanId = getters.currentDataset.scan; + if (getters.currentFrame) { + const curScanId = getters.currentFrame.scan; return state.scans[curScanId]; } return null; @@ -385,16 +385,16 @@ const { state.experiments = {}; state.experimentScans = {}; state.scans = {}; - state.scanDatasets = {}; - state.datasets = {}; + state.scanFrames = {}; + state.frames = {}; }, setCurrentFrameId(state, frameId) { - state.currentDatasetId = frameId; + state.currentFrameId = frameId; }, setFrame(state, { frameId, frame }) { // Replace with a new object to trigger a Vuex update - state.datasets = { ...state.datasets }; - state.datasets[frameId] = frame; + state.frames = { ...state.frames }; + state.frames[frameId] = frame; }, setScan(state, { scanId, scan }) { // Replace with a new object to trigger a Vuex update @@ -422,17 +422,17 @@ const { setActionTimeout(state, value) { state.actionTimeout = value; }, - setLoadingDataset(state, value) { - state.loadingDataset = value; + setLoadingFrame(state, value) { + state.loadingFrame = value; }, - setErrorLoadingDataset(state, value) { - state.errorLoadingDataset = value; + setErrorLoadingFrame(state, value) { + state.errorLoadingFrame = value; }, - addScanDatasets(state, { sid, id }) { - state.scanDatasets[sid].push(id); + addScanFrames(state, { sid, id }) { + state.scanFrames[sid].push(id); }, addExperimentScans(state, { eid, sid }) { - state.scanDatasets[sid] = []; + state.scanFrames[sid] = []; state.experimentScans[eid].push(sid); }, addExperiment(state, { id, value }) { @@ -475,7 +475,7 @@ const { } commit('reset'); fileCache.clear(); - datasetCache.clear(); + frameCache.clear(); }, async logout({ dispatch }) { dispatch('reset'); @@ -488,7 +488,7 @@ const { async loadProject({ commit }, project: Project) { commit('resetProject'); - // Build navigation links throughout the dataset to improve performance. + // Build navigation links throughout the frame to improve performance. let firstInPrev = null; // Refresh the project from the API @@ -532,7 +532,7 @@ const { name: scan.name, experiment: experiment.id, cumulativeRange: [Number.MAX_VALUE, -Number.MAX_VALUE], - numDatasets: frames.length, + numFrames: frames.length, // The experiment.scans.note serialization does not contain note metadata. // Just set notes to [] and let reloadScan set the complete values later. notes: [], @@ -540,11 +540,11 @@ const { }, }); - const nextScan = getNextDataset(experiments, i, j); + const nextScan = getNextFrame(experiments, i, j); for (let k = 0; k < frames.length; k += 1) { const frame = frames[k]; - commit('addScanDatasets', { sid: scan.id, id: frame.id }); + commit('addScanFrames', { sid: scan.id, id: frame.id }); commit('setFrame', { frameId: frame.id, frame: { @@ -552,10 +552,10 @@ const { scan: scan.id, experiment: experiment.id, index: k, - previousDataset: k > 0 ? frames[k - 1].id : null, - nextDataset: k < frames.length - 1 ? frames[k + 1].id : null, - firstDatasetInPreviousScan: firstInPrev, - firstDatasetInNextScan: nextScan ? nextScan.id : null, + previousFrame: k > 0 ? frames[k - 1].id : null, + nextFrame: k < frames.length - 1 ? frames[k + 1].id : null, + firstFrameInPreviousScan: firstInPrev, + firstFrameInNextScan: nextScan ? nextScan.id : null, }, }); } @@ -564,14 +564,14 @@ const { firstInPrev = frames[0].id; } else { console.error( - `${experiment.name}/${scan.name} has no datasets`, + `${experiment.name}/${scan.name} has no frames`, ); } } } }, async reloadScan({ commit, getters }) { - const currentFrame = getters.currentDataset; + const { currentFrame } = getters; // No need to reload if the frame doesn't exist or doesn't exist on the server if (!currentFrame || currentFrame.local) { return; @@ -589,7 +589,7 @@ const { name: scan.name, experiment: scan.experiment, cumulativeRange: [Number.MAX_VALUE, -Number.MAX_VALUE], - numDatasets: frames.length, + numFrames: frames.length, notes: scan.notes, decisions: scan.decisions, }, @@ -601,23 +601,23 @@ const { dispatch('reloadScan'); } }, - async swapToDataset({ + async swapToFrame({ state, dispatch, getters, commit, - }, dataset) { - if (!dataset) { - throw new Error("dataset id doesn't exist"); + }, frame) { + if (!frame) { + throw new Error("frame id doesn't exist"); } - if (getters.currentDataset === dataset) { + if (getters.currentFrame === frame) { return; } - commit('setLoadingDataset', true); - commit('setErrorLoadingDataset', false); + commit('setLoadingFrame', true); + commit('setErrorLoadingFrame', false); const oldScan = getters.currentScan; - const newScan = state.scans[dataset.scan]; + const newScan = state.scans[frame.scan]; const oldExperiment = getters.currentExperiment ? getters.currentExperiment : null; - const newExperimentId = state.scans[dataset.scan].experiment; + const newExperimentId = state.scans[frame.scan].experiment; const newExperiment = state.experiments[newExperimentId]; // Check if we should cancel the currently loading experiment @@ -663,10 +663,10 @@ const { // This try catch and within logic are mainly for handling data doesn't exist issue try { let frameData = null; - if (datasetCache.has(dataset.id)) { - frameData = datasetCache.get(dataset.id).frameData; + if (frameCache.has(frame.id)) { + frameData = frameCache.get(frame.id).frameData; } else { - const result = await loadFileAndGetData(dataset.id); + const result = await loadFileAndGetData(frame.id); frameData = result.frameData; } sourceProxy.setInputData(frameData); @@ -684,10 +684,10 @@ const { console.log('Caught exception loading next frame'); console.log(err); state.vtkViews = []; - commit('setErrorLoadingDataset', true); + commit('setErrorLoadingFrame', true); } finally { - dispatch('setCurrentFrame', dataset.id); - commit('setLoadingDataset', false); + dispatch('setCurrentFrame', frame.id); + commit('setLoadingFrame', false); } // If necessary, queue loading scans of new experiment diff --git a/client/src/utils/ReaderFactory.js b/client/src/utils/ReaderFactory.js index b7654ed6..78924df0 100644 --- a/client/src/utils/ReaderFactory.js +++ b/client/src/utils/ReaderFactory.js @@ -64,8 +64,8 @@ function readRawData({ fileName, data }) { } const ds = reader[parseMethod](data); Promise.resolve(ds) - .then((dataset) => resolve({ - dataset, + .then((frame) => resolve({ + frame, reader, sourceType, name: fileName, @@ -103,7 +103,7 @@ function loadFiles(files) { return Promise.all(promises); } -function downloadDataset(axios, fileName, url) { +function downloadFrame(axios, fileName, url) { return new Promise((resolve, reject, onCancel) => { const readerMapping = getReader({ name: fileName }); if (readerMapping) { @@ -128,7 +128,7 @@ function downloadDataset(axios, fileName, url) { } export default { - downloadDataset, + downloadFrame, loadFiles, registerReader, }; diff --git a/client/src/utils/helper.js b/client/src/utils/helper.js index 5d26e003..bb00c068 100644 --- a/client/src/utils/helper.js +++ b/client/src/utils/helper.js @@ -1,5 +1,5 @@ // eslint-disable-next-line import/prefer-default-export -export function cleanDatasetName(name) { +export function cleanFrameName(name) { const cleanName = name.replace(/^image/, '').replace(/.nii.gz$/, ''); if (cleanName === '') { return '1'; diff --git a/client/src/views/Dataset.vue b/client/src/views/Frame.vue similarity index 80% rename from client/src/views/Dataset.vue rename to client/src/views/Frame.vue index be0eb3a7..9a5395b1 100644 --- a/client/src/views/Dataset.vue +++ b/client/src/views/Frame.vue @@ -8,10 +8,10 @@ import Navbar from '@/components/Navbar.vue'; import ControlPanel from '@/components/ControlPanel.vue'; import ExperimentsView from '@/components/ExperimentsView.vue'; import VtkViewer from '@/components/VtkViewer.vue'; -import { cleanDatasetName } from '@/utils/helper'; +import { cleanFrameName } from '@/utils/helper'; export default { - name: 'Dataset', + name: 'Frame', components: { Navbar, ExperimentsView, @@ -23,16 +23,16 @@ export default { ...mapState([ 'vtkViews', 'scanCachedPercentage', - 'scanDatasets', - 'loadingDataset', - 'errorLoadingDataset', + 'scanFrames', + 'loadingFrame', + 'errorLoadingFrame', ]), ...mapGetters([ - 'getDataset', - 'currentDataset', + 'getFrame', + 'currentFrame', ]), - currentScanDatasets() { - return this.scanDatasets[this.currentScan.id]; + currentScanFrames() { + return this.scanFrames[this.currentScan.id]; }, }, watch: { @@ -46,23 +46,23 @@ export default { }, }, async created() { - this.debouncedDatasetSliderChange = _.debounce( - this.debouncedDatasetSliderChange, + this.debouncedFrameSliderChange = _.debounce( + this.debouncedFrameSliderChange, 30, ); - const { datasetId } = this.$route.params; - const dataset = this.getDataset(datasetId); - if (dataset) { - await this.swapToDataset(dataset); + const { frameId } = this.$route.params; + const frame = this.getFrame(frameId); + if (frame) { + await this.swapToFrame(frame); } else { this.$router.replace('/').catch(this.handleNavigationError); } }, async beforeRouteUpdate(to, from, next) { - const toDataset = this.getDataset(to.params.datasetId); + const toFrame = this.getFrame(to.params.frameId); next(true); - if (toDataset) { - this.swapToDataset(toDataset); + if (toFrame) { + this.swapToFrame(toFrame); } }, async beforeRouteLeave(to, from, next) { @@ -73,16 +73,16 @@ export default { 'loadProject', 'reloadScan', 'logout', - 'swapToDataset', + 'swapToFrame', ]), - cleanDatasetName, + cleanFrameName, async logoutUser() { await this.logout(); this.$router.go('/'); // trigger re-render into oauth flow }, - debouncedDatasetSliderChange(index) { - const datasetId = this.currentScanDatasets[index]; - this.$router.push(datasetId).catch(this.handleNavigationError); + debouncedFrameSliderChange(index) { + const frameId = this.currentScanFrames[index]; + this.$router.push(frameId).catch(this.handleNavigationError); }, advanceLoop() { if (this.scanning) { @@ -96,11 +96,11 @@ export default {