Beispiel #1
0
 def atlas_query_voxel(self, request, pk=None):
     ''' Returns the region name that matches specified coordinates in the specified atlas.\n 
     Parameters: x, y, z, collection, atlas \n
     Example: '/api/atlases/atlas_query_voxel/?x=30&y=30&z=30&collection=Harvard-Oxford cortical and subcortical structural atlases&atlas=HarvardOxford cort maxprob thr25 1mm' '''
     X = request.GET.get('x', '')
     Y = request.GET.get('y', '')
     Z = request.GET.get('z', '')
     collection = name = request.GET.get('collection', '')
     atlas = request.GET.get('atlas', '').replace('\'', '')
     try:
         collection_object = Collection.objects.filter(name=collection)[0]
     except IndexError:
         return JSONResponse('error: could not find collection: %s' %
                             collection,
                             status=400)
     try:
         print atlas
         print[
             x.name
             for x in Atlas.objects.filter(collection=collection_object)
         ]
         atlas_object = Atlas.objects.filter(
             name=atlas, collection=collection_object)[0]
         atlas_image = atlas_object.file
         atlas_xml = atlas_object.label_description_file
     except IndexError:
         return JSONResponse('error: could not find atlas: %s' % atlas,
                             status=400)
     try:
         data = voxelToRegion(X, Y, Z, atlas_image, atlas_xml)
     except IndexError:
         return JSONResponse(
             'error: one or more coordinates are out of range', status=400)
     return Response(data)
Beispiel #2
0
        collection = name=request.GET.get('collection','')
        atlas = request.GET.get('atlas','').replace('\'', '')
        try:
            collection_object = Collection.objects.filter(name=collection)[0]
        except IndexError:
            return JSONResponse('error: could not find collection: %s' % collection, status=400)
        try:
            print atlas
            print [x.name for x in Atlas.objects.filter(collection=collection_object)]
            atlas_object = Atlas.objects.filter(name=atlas, collection=collection_object)[0]
            atlas_image = atlas_object.file
            atlas_xml = atlas_object.label_description_file
        except IndexError:
            return JSONResponse('error: could not find atlas: %s' % atlas, status=400)
        try:
            data = voxelToRegion(X,Y,Z,atlas_image, atlas_xml)
        except IndexError:
            return JSONResponse('error: one or more coordinates are out of range', status=400)
        return Response(data)


class CollectionViewSet(mixins.RetrieveModelMixin,
                        mixins.ListModelMixin,
                        viewsets.GenericViewSet):

    queryset = Collection.objects.filter(private=False)
    filter_fields = ('name', 'DOI', 'owner')
    serializer_class = CollectionSerializer
    filter_backends = (DjangoFilterBackend,)

    @detail_route()