def export(self, nidm_version, export_dir):
        """
        Create prov entities and activities.
        """

        if self.masked_median is None:
            grand_mean_file = self.file.path
            grand_mean_img = nib.load(grand_mean_file)
            grand_mean_data = grand_mean_img.get_data()
            grand_mean_data = np.ndarray.flatten(grand_mean_data)

            mask_img = nib.load(self.mask_file)
            mask_data = mask_img.get_data()
            mask_data = np.ndarray.flatten(mask_data)

            grand_mean_data_in_mask = grand_mean_data[mask_data > 0]
            self.masked_median = np.median(
                np.array(grand_mean_data_in_mask, dtype=float))

        self.add_attributes((
            (PROV['type'], self.type),
            (PROV['label'], self.label),
            (NIDM_MASKED_MEDIAN, self.masked_median),
            (NIDM_IN_COORDINATE_SPACE, self.coord_space.id))
        )
def export ( self , nidm_version , export_dir ) : if self . masked_median is None : grand_mean_file = self . file . path grand_mean_img = nib . load ( grand_mean_file ) grand_mean_data = grand_mean_img . get_data ( ) grand_mean_data = np . ndarray . flatten ( grand_mean_data ) mask_img = nib . load ( self . mask_file ) mask_data = mask_img . get_data ( ) mask_data = np . ndarray . flatten ( mask_data ) grand_mean_data_in_mask = grand_mean_data [ mask_data > 0 ] self . masked_median = np . median ( np . array ( grand_mean_data_in_mask , dtype = float ) ) self . add_attributes ( ( ( PROV [ 'type' ] , self . type ) , ( PROV [ 'label' ] , self . label ) , ( NIDM_MASKED_MEDIAN , self . masked_median ) , ( NIDM_IN_COORDINATE_SPACE , self . coord_space . id ) ) )
Create prov entities and activities.