csv
oxytcmri.infrastructure.importers.csv
¶
Imports data from CSV files into repositories.
Classes:
Name | Description |
---|---|
CSVImporter |
Abstract base class for CSV importers. |
CSVCenterImporter |
Import centers from a CSV file to the repository. |
CSVAtlasImporter |
Service for importing atlas data from a CSV file. |
CSVNormativeDTIValuesImporter |
Service for importing normative DTI values from a CSV file. |
CSVImporter(filepath)
¶
Bases: Importer
, ABC
Abstract base class for CSV importers.
Attributes:
Name | Type | Description |
---|---|---|
csv_file_path |
str
|
The path to the CSV file. |
Source code in oxytcmri/infrastructure/importers/csv.py
30 31 32 33 34 |
|
csv_file_path = Path(filepath)
instance-attribute
¶
CSVCenterImporter(filepath, center_repository=None)
¶
Bases: CSVImporter
Import centers from a CSV file to the repository.
Attributes:
Name | Type | Description |
---|---|---|
csv_file_path |
str
|
The path to the CSV file. |
center_repository |
Optional[CenterRepository]
|
The repository to save the centers. |
Methods:
Name | Description |
---|---|
register_repository |
|
import_data |
Import centers from the CSV file to the repository. |
Source code in oxytcmri/infrastructure/importers/csv.py
49 50 51 |
|
center_repository = center_repository
instance-attribute
¶
register_repository(repositories)
¶
Source code in oxytcmri/infrastructure/importers/csv.py
53 54 55 56 |
|
import_data()
¶
Import centers from the CSV file to the repository.
Returns:
None
Source code in oxytcmri/infrastructure/importers/csv.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
CSVAtlasImporter(csv_file_path, atlas_repository=None)
¶
Bases: CSVImporter
Service for importing atlas data from a CSV file.
The CSV file should have the following format: id,name_atlas,label1,label2,label3,...
Attributes:
csv_file_path: str Path to the CSV file containing atlas data. atlas_repository: AtlasRepository Repository for storing atlas entities.
Initialize the importer.
Parameters:
csv_file_path: str
Path to the CSV file containing atlas data.
atlas_repository: AtlasRepository
Repository for storing atlas entities.
Methods:
Name | Description |
---|---|
register_repository |
|
import_data |
Import atlases from the CSV file. |
Attributes:
Name | Type | Description |
---|---|---|
atlas_repository |
|
Source code in oxytcmri/infrastructure/importers/csv.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
atlas_repository = atlas_repository
instance-attribute
¶
register_repository(repositories)
¶
Source code in oxytcmri/infrastructure/importers/csv.py
111 112 113 114 |
|
import_data()
¶
Import atlases from the CSV file.
The file has no header row.
Each line of the CSV file should have the format: id,name_atlas,label1,label2,label3,...
Source code in oxytcmri/infrastructure/importers/csv.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
CSVNormativeDTIValuesImporter(csv_file_path, center_repository=None, atlas_repository=None, normative_dti_values_repository=None)
¶
Bases: CSVImporter
Service for importing normative DTI values from a CSV file.
Initialize the importer.
Parameters:
csv_file_path: str
Path to the CSV file containing DTI values.
center_repository: Optional[CenterRepository]
Repository for retrieving center entities.
atlas_repository: Optional[AtlasRepository]
Repository for retrieving atlas entities.
normative_dti_values_repository: Optional[NormativeValueRepository]
Repository for storing normative DTI values.
Methods:
Name | Description |
---|---|
register_repository |
|
import_data |
Import normative DTI values from the CSV file. |
get_center_from_id |
Retrieve a center from its ID. |
get_atlas_from_id |
Retrieve an atlas from its ID. |
check_repositories |
Check if all required repositories are set. |
Attributes:
Name | Type | Description |
---|---|---|
center_repository |
|
|
atlas_repository |
|
|
normative_dti_values_repository |
|
Source code in oxytcmri/infrastructure/importers/csv.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
center_repository = center_repository
instance-attribute
¶
atlas_repository = atlas_repository
instance-attribute
¶
normative_dti_values_repository = normative_dti_values_repository
instance-attribute
¶
register_repository(repositories)
¶
Source code in oxytcmri/infrastructure/importers/csv.py
188 189 190 191 192 193 194 195 196 197 198 199 |
|
import_data()
¶
Import normative DTI values from the CSV file.
The CSV file should have the following columns: id,center_id,dti_metric,atlas_id,atlas_label,statistic_strategy,value
Source code in oxytcmri/infrastructure/importers/csv.py
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 |
|
get_center_from_id(center_id)
¶
Retrieve a center from its ID.
Parameters:
center_id: int
The ID of the center to retrieve.
Returns:
Center: The center with the given ID.
Raises:
ValueError: If the center is not found in the repository.
Source code in oxytcmri/infrastructure/importers/csv.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
get_atlas_from_id(atlas_id)
¶
Retrieve an atlas from its ID.
Parameters:
atlas_id: int
The ID of the atlas to retrieve.
Returns:
Atlas: The atlas with the given ID.
Raises:
ValueError: If the atlas is not found in the repository.
Source code in oxytcmri/infrastructure/importers/csv.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
|
check_repositories()
¶
Check if all required repositories are set.
Raises:
ValueError: If any repository is not set.
Source code in oxytcmri/infrastructure/importers/csv.py
280 281 282 283 284 285 286 287 288 289 290 291 292 |
|