def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: tsr = dao.get_generic_entity(TimeSeriesRegionIndex, self.handled_datatype.gid, "fk_region_mapping_volume_gid") tracts = dao.get_generic_entity(TractsIndex, self.handled_datatype.gid, "fk_region_volume_map_gid") error_msg = "RegionVolumeMappingIndex cannot be removed because is still used by %d %s entities." if len(tsr) > 0: raise RemoveDataTypeException(error_msg % (len(tsr), "TimeSeries")) if len(tracts) > 0: raise RemoveDataTypeException(error_msg % (len(tsr), "Tract")) conn_gid = self.handled_datatype.fk_connectivity_gid conn_measure_list = dao.get_generic_entity(ConnectivityMeasureIndex, conn_gid, "fk_connectivity_gid") others_rvm_list = dao.get_generic_entity(RegionVolumeMappingIndex, conn_gid, 'fk_connectivity_gid') if len(others_rvm_list) <= 1: # Only the current RegionVolumeMappingIndex is compatible for conn_measure_index in conn_measure_list: if conn_measure_index.has_volume_mapping: conn_measure_index.has_volume_mapping = False dao.store_entity(conn_measure_index) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesVolumeIndex, self.handled_datatype.gid, 'fk_volume_gid') associated_rvm = dao.get_generic_entity(RegionVolumeMappingIndex, self.handled_datatype.gid, 'fk_volume_gid') associated_s_mri = dao.get_generic_entity( StructuralMRIIndex, self.handled_datatype.gid, 'fk_volume_gid') error_msg = "Volume cannot be removed because is still used by a " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesVolume.") if len(associated_rvm) > 0: raise RemoveDataTypeException(error_msg + " RegionVolumeMapping.") if len(associated_s_mri) > 0: raise RemoveDataTypeException(error_msg + " StructuralMRI.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesSurfaceIndex, self.handled_datatype.gid, 'fk_surface_gid') associated_rm = dao.get_generic_entity(RegionMappingIndex, self.handled_datatype.gid, 'fk_surface_gid') associated_lc = dao.get_generic_entity(LocalConnectivityIndex, self.handled_datatype.gid, 'fk_surface_gid') associated_stim = dao.get_generic_entity(StimuliSurfaceIndex, self.handled_datatype.gid, 'fk_surface_gid') associated_pms = dao.get_generic_entity(ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_brain_skull_gid') associated_pms.extend(dao.get_generic_entity(ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_skull_skin_gid')) associated_pms.extend(dao.get_generic_entity(ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_skin_air_gid')) associated_pms.extend(dao.get_generic_entity(ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_source_gid')) error_msg = "Surface cannot be removed because is still used by %d %s entities " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg % (len(associated_ts), "TimeSeriesSurface")) if len(associated_rm) > 0: raise RemoveDataTypeException(error_msg % (len(associated_rm), "RegionMapping")) if len(associated_lc) > 0: raise RemoveDataTypeException(error_msg % (len(associated_lc), " LocalConnectivity")) if len(associated_stim) > 0: raise RemoveDataTypeException(error_msg % (len(associated_stim), "StimuliSurface")) if len(associated_pms) > 0: raise RemoveDataTypeException(error_msg % (len(associated_pms), "ProjectionMatrix")) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesSurface, self.handled_datatype.gid, '_surface') associated_rm = dao.get_generic_entity(RegionMapping, self.handled_datatype.gid, '_surface') associated_lc = dao.get_generic_entity(LocalConnectivity, self.handled_datatype.gid, '_surface') associated_stim = dao.get_generic_entity(StimuliSurfaceData, self.handled_datatype.gid, '_surface') error_msg = "Surface cannot be removed because is still used by a " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesSurface.") if len(associated_rm) > 0: raise RemoveDataTypeException(error_msg + " RegionMapping.") if len(associated_lc) > 0: raise RemoveDataTypeException(error_msg + " LocalConnectivity.") if len(associated_stim) > 0: raise RemoveDataTypeException(error_msg + " StimuliSurfaceData.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation = False): """ Called when a TimeSeries is removed. """ associated_cv = dao.get_generic_entity(Covariance, self.handled_datatype.gid, '_source') associated_pca = dao.get_generic_entity(PrincipalComponents, self.handled_datatype.gid, '_source') associated_is = dao.get_generic_entity(IndependentComponents, self.handled_datatype.gid, '_source') associated_cc = dao.get_generic_entity(CrossCorrelation, self.handled_datatype.gid, '_source') associated_fr = dao.get_generic_entity(FourierSpectrum, self.handled_datatype.gid, '_source') associated_wv = dao.get_generic_entity(WaveletCoefficients, self.handled_datatype.gid, '_source') associated_cs = dao.get_generic_entity(CoherenceSpectrum, self.handled_datatype.gid, '_source') associated_dm = dao.get_generic_entity(DatatypeMeasure, self.handled_datatype.gid, '_analyzed_datatype') for datatype_measure in associated_dm: datatype_measure._analyed_datatype = None dao.store_entity(datatype_measure) msg = "TimeSeries cannot be removed as it is used by at least one " if not skip_validation: if len(associated_cv) > 0: raise RemoveDataTypeException(msg + " Covariance.") if len(associated_pca) > 0: raise RemoveDataTypeException(msg + " PrincipalComponents.") if len(associated_is) > 0: raise RemoveDataTypeException(msg + " IndependentComponents.") if len(associated_cc) > 0: raise RemoveDataTypeException(msg + " CrossCorrelation.") if len(associated_fr) > 0: raise RemoveDataTypeException(msg + " FourierSpectrum.") if len(associated_wv) > 0: raise RemoveDataTypeException(msg + " WaveletCoefficients.") if len(associated_cs) > 0: raise RemoveDataTypeException(msg + " CoherenceSpectrum.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Connectivity is to be removed. """ key = 'fk_connectivity_gid' if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesRegionIndex, self.handled_datatype.gid, key) associated_rm = dao.get_generic_entity(RegionMappingIndex, self.handled_datatype.gid, key) associated_stim = dao.get_generic_entity(StimuliRegionIndex, self.handled_datatype.gid, key) associated_mes = dao.get_generic_entity(ConnectivityMeasureIndex, self.handled_datatype.gid, key) associated_rvm = dao.get_generic_entity(RegionVolumeMappingIndex, self.handled_datatype.gid, key) msg = "Connectivity cannot be removed as it is used by at least one " if len(associated_ts) > 0: raise RemoveDataTypeException(msg + " TimeSeriesRegion.") if len(associated_rm) > 0: raise RemoveDataTypeException(msg + " RegionMapping.") if len(associated_stim) > 0: raise RemoveDataTypeException(msg + " StimuliRegion.") if len(associated_mes) > 0: raise RemoveDataTypeException(msg + " ConnectivityMeasure.") if len(associated_rvm) > 0: raise RemoveDataTypeException(msg + " RegionVolumeMapping.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Connectivity is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesRegion, self.handled_datatype.gid, '_connectivity') associated_rm = dao.get_generic_entity(RegionMapping, self.handled_datatype.gid, '_connectivity') associated_stim = dao.get_generic_entity(StimuliRegion, self.handled_datatype.gid, '_connectivity') associated_mes = dao.get_generic_entity(ConnectivityMeasure, self.handled_datatype.gid, '_connectivity') msg = "Connectivity cannot be removed as it is used by at least one " if len(associated_ts) > 0: raise RemoveDataTypeException(msg + " TimeSeriesRegion.") if len(associated_rm) > 0: raise RemoveDataTypeException(msg + " RegionMapping.") if len(associated_stim) > 0: raise RemoveDataTypeException(msg + " StimuliRegion.") if len(associated_mes) > 0: raise RemoveDataTypeException(msg + " ConnectivityMeasure.") #### Update child Connectivities, if any. child_conns = dao.get_generic_entity(Connectivity, self.handled_datatype.gid, '_parent_connectivity') if len(child_conns) > 0: for one_conn in child_conns[1:]: one_conn.parent_connectivity = child_conns[0].gid if child_conns and child_conns[0]: child_conns[0].parent_connectivity = self.handled_datatype.parent_connectivity for one_child in child_conns: dao.store_entity(one_child) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: tsr = dao.get_generic_entity(TimeSeriesRegionIndex, self.handled_datatype.gid, self.FIELD_NAME) error_msg = "%s cannot be removed because is still used by %d TimeSeries Region entities." if tsr: raise RemoveDataTypeException(error_msg % (self.CLASS_NAME, len(tsr))) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: tsr = dao.get_generic_entity(TimeSeriesRegion, self.handled_datatype.gid, self.FIELD_NAME) error_msg = "%s cannot be removed because is still used by %d TimeSeries Region entities." if tsr: raise RemoveDataTypeException(error_msg % (self.CLASS_NAME, len(tsr))) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: projection_matrices = dao.get_generic_entity(ProjectionMatrix, self.handled_datatype.gid, '_sensors') error_msg = "Sensor cannot be removed because is still used by %d Projection Matrix entities." if projection_matrices: raise RemoveDataTypeException(error_msg % len(projection_matrices)) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a TimeSeries is removed. """ if not skip_validation: associated_cv = dao.get_generic_entity(Covariance, self.handled_datatype.gid, '_source') associated_pca = dao.get_generic_entity(PrincipalComponents, self.handled_datatype.gid, '_source') associated_is = dao.get_generic_entity(IndependentComponents, self.handled_datatype.gid, '_source') associated_cc = dao.get_generic_entity(CrossCorrelation, self.handled_datatype.gid, '_source') associated_fr = dao.get_generic_entity(FourierSpectrum, self.handled_datatype.gid, '_source') associated_wv = dao.get_generic_entity(WaveletCoefficients, self.handled_datatype.gid, '_source') associated_cs = dao.get_generic_entity(CoherenceSpectrum, self.handled_datatype.gid, '_source') msg = "TimeSeries cannot be removed as it is used by at least one " if len(associated_cv) > 0: raise RemoveDataTypeException(msg + " Covariance.") if len(associated_pca) > 0: raise RemoveDataTypeException(msg + " PrincipalComponents.") if len(associated_is) > 0: raise RemoveDataTypeException(msg + " IndependentComponents.") if len(associated_cc) > 0: raise RemoveDataTypeException(msg + " CrossCorrelation.") if len(associated_fr) > 0: raise RemoveDataTypeException(msg + " FourierSpectrum.") if len(associated_wv) > 0: raise RemoveDataTypeException(msg + " WaveletCoefficients.") if len(associated_cs) > 0: raise RemoveDataTypeException(msg + " CoherenceSpectrum.") # todo: reconsider this. Possibly remove measures associated_dm = dao.get_generic_entity(DatatypeMeasure, self.handled_datatype.gid, '_analyzed_datatype') for datatype_measure in associated_dm: datatype_measure._analyed_datatype = None dao.store_entity(datatype_measure) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: projection_matrices = dao.get_generic_entity( ProjectionMatrix, self.handled_datatype.gid, '_sensors') error_msg = "Sensor cannot be removed because is still used by %d Projection Matrix entities." if projection_matrices: raise RemoveDataTypeException(error_msg % len(projection_matrices)) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: projection_matrices_brain = dao.get_generic_entity( ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_brain_skull_gid') projection_matrices_skull = dao.get_generic_entity( ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_skull_skin_gid') projection_matrices_skin = dao.get_generic_entity( ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_skin_air_gid') projection_matrices_source = dao.get_generic_entity( ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_source_gid') projection_matrices_sensors = dao.get_generic_entity( ProjectionMatrixIndex, self.handled_datatype.gid, 'fk_sensors_gid') ts_seeg = dao.get_generic_entity(TimeSeriesSEEGIndex, self.handled_datatype.gid, 'fk_sensors_gid') ts_meg = dao.get_generic_entity(TimeSeriesMEGIndex, self.handled_datatype.gid, 'fk_sensors_gid') ts_eeg = dao.get_generic_entity(TimeSeriesEEGIndex, self.handled_datatype.gid, 'fk_sensors_gid') error_msg = "Cannot be removed as it is used by at least one " if len(projection_matrices_brain) > 0: raise RemoveDataTypeException(error_msg + " Brain Skull.") if len(projection_matrices_skull) > 0: raise RemoveDataTypeException(error_msg + " Skull Skin.") if len(projection_matrices_skin) > 0: raise RemoveDataTypeException(error_msg + " Skin Air.") if len(projection_matrices_source) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesSEEG.") if len(ts_seeg) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesMEG.") if len(ts_meg) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesEEG.") if len(ts_eeg) > 0: raise RemoveDataTypeException(error_msg + " Source.") if len(projection_matrices_sensors) > 0: raise RemoveDataTypeException(error_msg % len(projection_matrices_sensors)) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation = False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesVolume, self.handled_datatype.gid, '_volume') associated_stim = dao.get_generic_entity(SpatialPatternVolume, self.handled_datatype.gid, '_volume') error_msg = "Surface cannot be removed because is still used by a " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesVolume.") if len(associated_stim) > 0: raise RemoveDataTypeException(error_msg + " SpatialPatternVolume.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesVolume, self.handled_datatype.gid, '_volume') associated_stim = dao.get_generic_entity(SpatialPatternVolume, self.handled_datatype.gid, '_volume') error_msg = "Surface cannot be removed because is still used by a " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesVolume.") if len(associated_stim) > 0: raise RemoveDataTypeException(error_msg + " SpatialPatternVolume.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Connectivity is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesRegion, self.handled_datatype.gid, '_connectivity') associated_rm = dao.get_generic_entity(RegionMapping, self.handled_datatype.gid, '_connectivity') associated_stim = dao.get_generic_entity(StimuliRegion, self.handled_datatype.gid, '_connectivity') associated_mes = dao.get_generic_entity(ConnectivityMeasure, self.handled_datatype.gid, '_connectivity') msg = "Connectivity cannot be removed as it is used by at least one " if len(associated_ts) > 0: raise RemoveDataTypeException(msg + " TimeSeriesRegion.") if len(associated_rm) > 0: raise RemoveDataTypeException(msg + " RegionMapping.") if len(associated_stim) > 0: raise RemoveDataTypeException(msg + " StimuliRegion.") if len(associated_mes) > 0: raise RemoveDataTypeException(msg + " ConnectivityMeasure.") #### Update child Connectivities, if any. child_conns = dao.get_generic_entity(Connectivity, self.handled_datatype.gid, '_parent_connectivity') if len(child_conns) > 0: for one_conn in child_conns[1:]: one_conn.parent_connectivity = child_conns[0].gid if child_conns and child_conns[0]: child_conns[ 0].parent_connectivity = self.handled_datatype.parent_connectivity for one_child in child_conns: dao.store_entity(one_child) ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Surface is to be removed. """ if not skip_validation: associated_ts = dao.get_generic_entity(TimeSeriesSurface, self.handled_datatype.gid, '_surface') associated_rm = dao.get_generic_entity(RegionMapping, self.handled_datatype.gid, '_surface') associated_lc = dao.get_generic_entity(LocalConnectivity, self.handled_datatype.gid, '_surface') associated_stim = dao.get_generic_entity(StimuliSurface, self.handled_datatype.gid, '_surface') error_msg = "Surface cannot be removed because is still used by a " if len(associated_ts) > 0: raise RemoveDataTypeException(error_msg + " TimeSeriesSurface.") if len(associated_rm) > 0: raise RemoveDataTypeException(error_msg + " RegionMapping.") if len(associated_lc) > 0: raise RemoveDataTypeException(error_msg + " LocalConnectivity.") if len(associated_stim) > 0: raise RemoveDataTypeException(error_msg + " StimuliSurfaceData.") ABCRemover.remove_datatype(self, skip_validation)
def remove_datatype(self, skip_validation=False): """ Called when a Sensor is to be removed. """ if not skip_validation: key = 'fk_sensors_gid' projection_matrices_sensors = dao.get_generic_entity(ProjectionMatrixIndex, self.handled_datatype.gid, key) ts_seeg = dao.get_generic_entity(TimeSeriesSEEGIndex, self.handled_datatype.gid, key) ts_meg = dao.get_generic_entity(TimeSeriesMEGIndex, self.handled_datatype.gid, key) ts_eeg = dao.get_generic_entity(TimeSeriesEEGIndex, self.handled_datatype.gid, key) error_msg = "Cannot be removed as it is used by %d %s entities." if len(ts_seeg) > 0: raise RemoveDataTypeException(error_msg % (len(ts_seeg),"TimeSeriesSEEG")) if len(ts_meg) > 0: raise RemoveDataTypeException(error_msg % (len(ts_meg),"TimeSeriesMEG")) if len(ts_eeg) > 0: raise RemoveDataTypeException(error_msg % (len(ts_eeg),"TimeSeriesEEG")) if len(projection_matrices_sensors) > 0: raise RemoveDataTypeException(error_msg % (len(projection_matrices_sensors),"ProjectionMatrix")) ABCRemover.remove_datatype(self, skip_validation)
def __init__(self, handled_datatype): ABCRemover.__init__(self, handled_datatype)
def remove_datatype(self, skip_validation=False): """ Called when a TimeSeries is removed. """ if not skip_validation: key = 'fk_source_gid' associated_fcd = dao.get_generic_entity(FcdIndex, self.handled_datatype.gid, key) associated_cv = dao.get_generic_entity(CovarianceIndex, self.handled_datatype.gid, key) associated_pca = dao.get_generic_entity(PrincipalComponentsIndex, self.handled_datatype.gid, key) associated_is = dao.get_generic_entity(IndependentComponentsIndex, self.handled_datatype.gid, key) associated_cc = dao.get_generic_entity(CrossCorrelationIndex, self.handled_datatype.gid, key) associated_fr = dao.get_generic_entity(FourierSpectrumIndex, self.handled_datatype.gid, key) associated_wv = dao.get_generic_entity(WaveletCoefficientsIndex, self.handled_datatype.gid, key) associated_cs = dao.get_generic_entity(CoherenceSpectrumIndex, self.handled_datatype.gid, key) associated_coef = dao.get_generic_entity( CorrelationCoefficientsIndex, self.handled_datatype.gid, key) associated_dtm = dao.get_generic_entity(DatatypeMeasureIndex, self.handled_datatype.gid, key) associated_ccs = dao.get_generic_entity( ComplexCoherenceSpectrumIndex, self.handled_datatype.gid, key) msg = "TimeSeries cannot be removed as it is used by at least one " if len(associated_fcd) > 0: raise RemoveDataTypeException(msg + " FCD.") if len(associated_cv) > 0: raise RemoveDataTypeException(msg + " Covariance.") if len(associated_pca) > 0: raise RemoveDataTypeException(msg + " PrincipalComponents.") if len(associated_is) > 0: raise RemoveDataTypeException(msg + " IndependentComponents.") if len(associated_cc) > 0: raise RemoveDataTypeException(msg + " CrossCorrelation.") if len(associated_fr) > 0: raise RemoveDataTypeException(msg + " FourierSpectrum.") if len(associated_wv) > 0: raise RemoveDataTypeException(msg + " WaveletCoefficients.") if len(associated_cs) > 0: raise RemoveDataTypeException(msg + " CoherenceSpectrum.") if len(associated_coef) > 0: raise RemoveDataTypeException(msg + " CorrelationCoefficient.") if len(associated_dtm) > 0: raise RemoveDataTypeException(msg + " DatatypeMeasure.") if len(associated_ccs) > 0: raise RemoveDataTypeException(msg + " ComplexCoherenceSpectrum.") ABCRemover.remove_datatype(self, skip_validation)