8 Commits 2f9bbd523c ... b7177a71de

Author SHA1 Message Date
  Felix Schultze b7177a71de Merge branch 'otherteststructure' of git.ipe.kit.edu:schultze/volume-visualization into otherteststructure 9 years ago
  Felix Schultze 2f11edc202 undisplay container-overview till width of 970px 9 years ago
  Felix Schultze d878d51f49 Merge branch 'otherteststructure' of git.ipe.kit.edu:schultze/volume-visualization into otherteststructure 9 years ago
  Felix Schultze 217a74a7a7 get average in csv 9 years ago
  Felix Schultze 5ca3797558 Merge branch 'otherteststructure' of git.ipe.kit.edu:schultze/volume-visualization into otherteststructure 9 years ago
  Felix Schultze 432690cbf9 Other way of stream images to client 9 years ago
  Felix Schultze 0a9d2f0a4f Merge branch 'master' into otherteststructure 9 years ago
  Felix Schultze 6bb2ab9cbc changed teststructure 9 years ago

+ 3 - 2
loadtests/facade.py

@@ -1,6 +1,7 @@
 from .testmodels import TestRun
 
 
-def addTestResult(testId, inputShape, subvolumeShape, pointAsTuple, durationInSec, duration_copy_in_sec, dtype):
+def addTestResult(testId, inputShape, subvolumeShape, pointAsTuple, durationInSec, duration_copy_in_sec, dtype, volume_id=''):
+    ''' add a test result at once to the testId '''
     test = TestRun.objects(id=testId).first()
-    test.addTestResult(inputShape, subvolumeShape, pointAsTuple, durationInSec, duration_copy_in_sec, dtype)
+    test.addTestResult(inputShape, subvolumeShape, pointAsTuple, durationInSec, duration_copy_in_sec, dtype, str(volume_id))

+ 18 - 1
loadtests/testmodels.py

@@ -17,6 +17,7 @@ class Result(EmbeddedDocument):
     duration_copy_in_sec = FloatField()
     point = EmbeddedDocumentField(Dim)
     itemsize = IntField()
+    volume_id = StringField()
 
     @property
     def get_copy_throughput(self):
@@ -27,16 +28,28 @@ class Result(EmbeddedDocument):
 
         return number_of_items / self.duration_copy_in_sec / 1024 / 1024
 
+    @property
+    def volume_name(self):
+        if self.volumeId is None:
+            return ''
+
+        volumes = Volume.objects(id=self.volumeId)
+
+        if volumes is None:
+            return self.volumeId
+        else:
+            return volumes.first().name
 
 class TestRun(Document):
     name = StringField()
+    # for compatibilityreasons, it's left in here
     volumeId = StringField()
     results = ListField(EmbeddedDocumentField(Result))
     created = DateTimeField()
 
     meta = {"db_alias": "test_results"}
 
-    def addTestResult(self, originalShape, subvolumeShape, subvolumePoint, durationInSec, duration_copy_in_sec, dtype):
+    def addTestResult(self, originalShape, subvolumeShape, subvolumePoint, durationInSec, duration_copy_in_sec, dtype, volume_id):
         result = Result()
 
         inputSize = Dim()
@@ -54,11 +67,15 @@ class TestRun(Document):
         result.durationInSec = durationInSec
         result.duration_copy_in_sec = duration_copy_in_sec
         result.itemsize = dtype.itemsize
+        result.volume_id = volume_id
 
         TestRun.objects(id=self.id).update_one(push__results=result)
 
     @property
     def volume_name(self):
+        if self.volumeId is None:
+            return ''
+
         volumes = Volume.objects(id=self.volumeId)
 
         if volumes is None:

+ 1 - 1
loadtests/urls.py

@@ -7,7 +7,7 @@ from . import views
 urlpatterns = patterns(
     '',
     url(r'^$', views.index, name='home'),
-    url(r'^init/(?P<volumeId>[\da-z]+)/(?P<testName>[\da-z+*_/%]+)/$', views.testsetup),
+    url(r'^init/(?P<testName>[\da-z+*_/%]+)/$', views.testsetup),
     url(r'^delete/(?P<id>[\da-z]+)/$', views.deletetest, name='delete'),
     url(r'^csv/(?P<id>[\da-z]+)/$', views.createcsv, name='createcsv')
 )

+ 3 - 2
loadtests/views.py

@@ -20,10 +20,9 @@ def index(request):
     return render(request, 'loadtests/index.html', {'tests': tests})
 
 
-def testsetup(request, volumeId, testName):
+def testsetup(request, testName):
     test = TestRun()
     test.name = testName
-    test.volumeId = volumeId
     test.created = datetime.now()
     test = test.save()
     response = HttpResponse('{ "testId": ' + str(test.id) + ' }', content_type='json')
@@ -54,6 +53,8 @@ def createcsv(request, id):
     for result in test.results:
         writer.writerow([result.durationInSec])
 
+    writer.writerow(['average', test.get_average])
+
     return response
 
 

+ 6 - 0
static/css/application.css

@@ -407,6 +407,12 @@ div#opacity-buttons {
     }
 }
 
+@media (max-width: 970px) {
+    div#container-overview {
+        display: none;
+    }
+}
+
 @media (min-width: 1850px) {
     div#axis-container {
         width: 40%;

+ 9 - 5
volumes/processing/service/SubvolumeCreator.py

@@ -9,6 +9,8 @@ import numpy as np
 import os
 from PIL import Image
 from skimage import img_as_ubyte
+from skimage.transform import resize
+from skimage.io import imsave
 import time
 from threading import Thread
 
@@ -85,13 +87,12 @@ def subvolumeCreator(volumeId, x, y, z, t, minWidth, sqrtZ, numberOfLayers, spri
     logger.debug('layers per row: %d' % sqrtZ)
     layerCounter = 0
     copy_start_time = time.time()
-    for index in range(z, z + numberOfLayers):
-        zlayer = imageAsArray[index]
-
+    zArea = imageAsArray[z:z+numberOfLayers, :, :]
+    for index in range(0, numberOfLayers):
         yoffset = math.floor(layerCounter / sqrtZ) * minWidth
         xoffset = (layerCounter % sqrtZ) * minWidth
 
-        subvolume[yoffset: yoffset+minWidth, xoffset: xoffset+minWidth] = zlayer[y: y+minWidth, x: x+minWidth]
+        subvolume[yoffset: yoffset+minWidth, xoffset: xoffset+minWidth] = zArea[index, y: y+minWidth, x: x+minWidth]
 
         layerCounter += 1
 
@@ -100,9 +101,11 @@ def subvolumeCreator(volumeId, x, y, z, t, minWidth, sqrtZ, numberOfLayers, spri
     subvolume = img_as_ubyte(subvolume)
     image = Image.fromarray(subvolume)
     image = image.resize(requestedShape, resample=Image.BILINEAR)
+    # subvolume = resize(subvolume, requestedShape)               
     format = spriteformat
     buff = io.BytesIO()
     image.save(buff, format=format, progressive=True, quality=95)
+    # imsave(buff, subvolume, pluginargs={'progressive':True, 'quality':95})
     buff.seek(0, 0)
     spriteFilename = get_sprite_filename(spriteId, spriteformat)
 
@@ -124,7 +127,8 @@ def subvolumeCreator(volumeId, x, y, z, t, minWidth, sqrtZ, numberOfLayers, spri
             (x, y, z),
             processing_duration,
             copy_duration,
-            imageAsArray.dtype
+            imageAsArray.dtype,
+            volumeId
         )
     else:
         logger.debug('no testid given')

+ 15 - 5
volumes/views.py

@@ -1,8 +1,9 @@
 from django.core.urlresolvers import reverse
 from django.shortcuts import render, render_to_response
 from django.template import RequestContext
-from django.http import HttpResponseRedirect, HttpResponse
+from django.http import HttpResponseRedirect, HttpResponse, StreamingHttpResponse
 from django.contrib import messages
+from django.core.servers.basehttp import FileWrapper
 
 from django.conf import settings
 
@@ -105,10 +106,11 @@ def addList(request):
         volumesToProcess = []
 
         for path in paths:
-            pathParts = path.split('/')
+            pathParts = path.split(':')
+
             volume = Volume()
-            volume.name = pathParts[5] + '_____' + pathParts[7]
-            volume.path = path.strip()
+            volume.name = pathParts[0].strip()
+            volume.path = pathParts[1].strip()
             volume.imageSequence = imageSequences
             volume = volume.save()
             volumesToProcess.append(volume.id)
@@ -157,10 +159,18 @@ def showSprite(request, id, spriteId):
     if contenttype is None:
         contenttype = 'image/jpeg'
 
+    chunk_size = 8192
+    response = StreamingHttpResponse(FileWrapper(sprite, chunk_size),
+                                     content_type=contenttype)
+    response['Content-Length'] = sprite.length
+    response['Content-Disposition'] = "attachment; filename=%s" % sprite._id
+    return response
+    '''
     response = HttpResponse(sprite.read(), content_type=contenttype)
     response['Content-Length'] = sprite.length
 
     return response
+    '''
 
 
 def getTextureInfo(request, id, size):
@@ -206,7 +216,7 @@ def render3D(request, id, res=None):
     if res is not None:
         res = int(res)
 
-    SubvolumeCreator.preread_volume(id)
+    #SubvolumeCreator.preread_volume(id)
 
     requestedResFound = False
     sizes = []