0

想知道为什么以及何时需要在 datajoint 的自动填充表中的 make/maketuples 函数中将键设置为不同的变量,如此处的文档中所示

在本例中,零件表 SegmentationROI 定义如下:

%{
# Region of interest resulting from segmentation
-> test.Segmentation
roi  : smallint   # roi number
---
roi_pixels  : longblob   #  indices of pixels
roi_weights : longblob   #  weights of pixels
%}

classdef SegmentationROI < dj.Part
    properties(SetAccess=protected)
        master = test.Segmentation
    end
    methods
        function make(self, key)
            image = fetch1(test.Image & key, 'image');
            [roi_pixels, roi_weighs] = mylib.segment(image);
            for roi=1:length(roi_pixels)
                entity = key;
                entity.roi_pixels = roi_pixels{roi};
                entity.roi_weights = roi_weights{roi};
                self.insert(entity)
            end
        end
    end
end

将键重命名为单独的变量实体(实体 = 键)然后插入它的目的是什么?

4

1 回答 1

3

在这种情况下,我们将字段添加entity为结构。我认为最好的做法是按原样保留函数的参数。key如果我们在此处添加第二个 for 循环,则在调用其他目的时可能会遇到问题。

警告:我更熟悉 DataJoint python,并没有在 MATLAB 中广泛使用它。

于 2021-12-03T15:50:29.137 回答