示例#1
0
    def put(self, request):
        request_data = request.data

        if request_data is None:
            return ResponseDto(success=False, message='请携带有效的seriesuid')
        seriesuid = request_data['params']['updates'][0]['value']
        seriespath = file_path_ferry.splitDicomPath + str(seriesuid)

        if not os.path.exists(seriespath):
            return ResponseDto(success=False, message='请确认series数据是否存在')

        if len(os.listdir(seriespath)) <= 1:
            return ResponseDto(success=False,
                               message='series下的dicom文件单一,无法build volume')

        try:
            builder = VolumeBuilder()
            volfilepath, seriesuid = builder.build(seriespath)
        except Exception as e:
            return ResponseDto(success=True, message='dicom文件不符合规范,创建volume失败')

        success, msg = series_svc.upload_volume(volfilepath, seriesuid)
        if not success:
            return ResponseDto(success=success, message=msg)

        try:
            return sync_send_command('load', volumepath=volfilepath)
        except Exception as e:
            return ResponseDto(success=False, message=e.message)
示例#2
0
 def post(self, request):
     try:
         sizedata = request.data.get('view_size', None)
         if sizedata is None:
             return ResponseDto(success=False, message='sizedata is None')
         return sync_send_command('resize', view_size=sizedata)
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#3
0
 def get(self, request):
     try:
         colormode = request.GET.get('colormode', '0')
         display_view = request.GET.get('display_view', 'all')
         return sync_send_command('color',
                                  colormode=colormode,
                                  display_view=display_view)
     except Exception as e:
         return ResponseDto(success=True, message=e.message)
示例#4
0
 def get(self, request):
     """
     Reset voulme data
     :return: True or False
     """
     try:
         return sync_send_command('reset')
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#5
0
 def get(self, request):
     """
     the client request loads a series and get images
     :return: rgb image data
     """
     try:
         return sync_send_command('show')
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#6
0
 def put(self, request):
     cps = [request.data.get('contours', None)]
     contour_uid = request.data.get('contour_uid', None)
     rst = sync_send_command('point2dto3d', contours=cps)
     if not rst.data['success']:
         return rst
     cps = json.loads(rst.data['data'])['contours']
     success, msg = contour_svc.update_by_contouruid(contour_uid, cps)
     return ResponseDto(success=success, message=msg)
示例#7
0
 def get(self, request):
     roi_uids = request.GET.get('roi_uids', None)
     slice_index = request.GET.get('slice_index', None)
     roi_uids = roi_uids.split(',')
     contours, msg = contour_svc.retrieve(slice_index, roi_uids)
     if contours is None:
         return ResponseDto(success=False, message=msg)
     for contour in contours:
         rst = sync_send_command('point3dto2d', contour=contour['cps'])
         contour['cps'] = json.loads(rst.data['data'])['contour']
     return ResponseDto(data=contours)
示例#8
0
    def get(self, request):
        try:
            cross_point = request.GET.get('cross_point', None)
            focus_view = request.GET.get('focus_view', None)

            if not cross_point or not focus_view:
                return ResponseDto(success=False, message='请求参数不完整')
            return sync_send_command('locate',
                                     cross_point=cross_point,
                                     focus_view=focus_view)
        except Exception as e:
            return ResponseDto(success=False, message=e.message)
示例#9
0
    def delete(self, request):
        """
        the client request unload volume data from memory
        :param seriesuid: series uid
        :return:boolean true for success, false for failure
        """
        try:
            seriesuid = request.GET.get('seriesuid', None)
            if seriesuid is None:
                return ResponseDto(success=False, message='seriesuid is None')

            return sync_send_command('unload', seriesuid=seriesuid)
        except Exception as e:
            return ResponseDto(success=False, message=e.message)
示例#10
0
 def get(self, request):
     """
     Change window center and window width
     :param ww: ww
     :param wl: wl
     :return: rgb image data
     """
     try:
         ww = request.GET.get('ww', None)
         wl = request.GET.get('wl', None)
         if ww is None or wl is None:
             return ResponseDto(success=False, message='请输入完整的请求数据')
         return sync_send_command('wwwl', ww=ww, wl=wl)
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#11
0
 def get(self, request):
     """
     Page turning
     :param delta: cursor delta
     :param focus_view: current focused view, 'transverse' for transverse,
           'saggital' for saggital, 'coronal' for coronal
     :return: rgb image data
     """
     try:
         delta = request.GET.get('delta', '0')
         focus_view = request.GET.get('focus_view', None)
         return sync_send_command('page',
                                  delta=delta,
                                  focus_view=focus_view)
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#12
0
 def get(self, request):
     """
     roll
     :param cursor: the 3d world coordinate of a cursor, like [1,1,2], you should pass it like `'1,1,2'`
     :param focus_view: current focused view, 'transverse' for transverse,
           'saggital' for saggital, 'coronal' for coronal
     :return: rgb image data
     """
     try:
         cursor = request.GET.get('cursor', '0')
         focus_view = request.GET.get('focus_view', None)
         return sync_send_command('roll',
                                  cursor=cursor,
                                  focus_view=focus_view)
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#13
0
 def post(self, request):
     roi_uid = request.data.get('roi_uid', None)
     slice_index = request.data.get('slice_index', None)
     contours = request.data.get('contours', None)
     contour_type = int(request.data.get('contour_type', None))
     contour_uid = request.data.get('contour_uid', None)
     rst = sync_send_command('point2dto3d', contours=contours)
     if not rst.data['success']:
         return rst
     contours = json.loads(rst.data['data'])['contours']
     if contour_type == 0 or contour_uid is None:
         success, msg = contour_svc.create(slice_index, roi_uid, contours,
                                           contour_type)
     else:
         success, msg = contour_svc.create_by_contouruid(
             slice_index, roi_uid, contours, contour_type, contour_uid)
     return ResponseDto(success=success, message=msg)
示例#14
0
 def get(self, request):
     """
     Zoom
     :param shift: zoom factor shift
     :param focus_view: current focused view, 'transverse' for transverse,
           'saggital' for saggital, 'coronal' for coronal
     :return: rgb image data
     """
     try:
         zoom_factor = request.GET.get('zoom_factor', '0')
         focus_view = request.GET.get('focus_view', None)
         if focus_view is None:
             return ResponseDto(success=False, message='请输入完整的请求数据')
         return sync_send_command('zoom',
                                  zoom_factor=zoom_factor,
                                  focus_view=focus_view)
     except Exception as e:
         return ResponseDto(success=False, message=e.message)
示例#15
0
    def get(self, request):
        """
        Rotate
        :param angle: rotate angle
        :param focus_view: current focused view, 'transverse' for transverse,
              'saggital' for saggital, 'coronal' for coronal
        :return: rgb image data
        """
        try:
            pos_pre = request.GET.get('pos_pre', None)
            pos_cur = request.GET.get('pos_cur', None)
            focus_view = request.GET.get('focus_view', None)
            if pos_pre is None or pos_cur is None or focus_view is None:
                return ResponseDto(success=False, message='请输入完整的请求数据')

            return sync_send_command('rotate',
                                     pos_pre=pos_pre,
                                     pos_cur=pos_cur,
                                     focus_view=focus_view)
        except Exception as e:
            return ResponseDto(success=False, message=e.message)
示例#16
0
 def get(self, request):
     """
     translation
     :param shift: center shift, like [1,1,2], you should pass it like `'1,1,2'`
     :param focus_view: current focused view, 'transverse' for transverse,
           'saggital' for saggital, 'coronal' for coronal
     :param display_view: need to displayed on screen, 'transverse' for transverse,
           'saggital' for saggital, 'coronal' for coronal, 'all' for all view
     :return: rgb image data
     """
     try:
         pos_pre = request.GET.get('pos_pre', None)
         pos_cur = request.GET.get('pos_cur', None)
         focus_view = request.GET.get('focus_view', None)
         if pos_pre is None or pos_cur is None:
             return ResponseDto(success=False, message='请输入完整的请求数据')
         return sync_send_command('pan',
                                  pos_pre=pos_pre,
                                  pos_cur=pos_cur,
                                  focus_view=focus_view)
     except Exception as e:
         return ResponseDto(success=True, message=e.message)
示例#17
0
 def get(self, request):
     try:
         return sync_send_command('center')
     except Exception as e:
         return ResponseDto(success=False, message=e.message)