brkraw 0.3.11__py3-none-any.whl → 0.5.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. brkraw/__init__.py +9 -3
  2. brkraw/apps/__init__.py +12 -0
  3. brkraw/apps/addon/__init__.py +30 -0
  4. brkraw/apps/addon/core.py +35 -0
  5. brkraw/apps/addon/dependencies.py +402 -0
  6. brkraw/apps/addon/installation.py +500 -0
  7. brkraw/apps/addon/io.py +21 -0
  8. brkraw/apps/hook/__init__.py +25 -0
  9. brkraw/apps/hook/core.py +636 -0
  10. brkraw/apps/loader/__init__.py +10 -0
  11. brkraw/apps/loader/core.py +622 -0
  12. brkraw/apps/loader/formatter.py +288 -0
  13. brkraw/apps/loader/helper.py +797 -0
  14. brkraw/apps/loader/info/__init__.py +11 -0
  15. brkraw/apps/loader/info/scan.py +85 -0
  16. brkraw/apps/loader/info/scan.yaml +90 -0
  17. brkraw/apps/loader/info/study.py +69 -0
  18. brkraw/apps/loader/info/study.yaml +156 -0
  19. brkraw/apps/loader/info/transform.py +92 -0
  20. brkraw/apps/loader/types.py +220 -0
  21. brkraw/cli/__init__.py +5 -0
  22. brkraw/cli/commands/__init__.py +2 -0
  23. brkraw/cli/commands/addon.py +327 -0
  24. brkraw/cli/commands/config.py +205 -0
  25. brkraw/cli/commands/convert.py +903 -0
  26. brkraw/cli/commands/hook.py +348 -0
  27. brkraw/cli/commands/info.py +74 -0
  28. brkraw/cli/commands/init.py +214 -0
  29. brkraw/cli/commands/params.py +106 -0
  30. brkraw/cli/commands/prune.py +288 -0
  31. brkraw/cli/commands/session.py +371 -0
  32. brkraw/cli/hook_args.py +80 -0
  33. brkraw/cli/main.py +83 -0
  34. brkraw/cli/utils.py +60 -0
  35. brkraw/core/__init__.py +13 -0
  36. brkraw/core/config.py +380 -0
  37. brkraw/core/entrypoints.py +25 -0
  38. brkraw/core/formatter.py +367 -0
  39. brkraw/core/fs.py +495 -0
  40. brkraw/core/jcamp.py +600 -0
  41. brkraw/core/layout.py +451 -0
  42. brkraw/core/parameters.py +781 -0
  43. brkraw/core/zip.py +1121 -0
  44. brkraw/dataclasses/__init__.py +14 -0
  45. brkraw/dataclasses/node.py +139 -0
  46. brkraw/dataclasses/reco.py +33 -0
  47. brkraw/dataclasses/scan.py +61 -0
  48. brkraw/dataclasses/study.py +131 -0
  49. brkraw/default/__init__.py +3 -0
  50. brkraw/default/pruner_specs/deid4share.yaml +42 -0
  51. brkraw/default/rules/00_default.yaml +4 -0
  52. brkraw/default/specs/metadata_dicom.yaml +236 -0
  53. brkraw/default/specs/metadata_transforms.py +92 -0
  54. brkraw/resolver/__init__.py +7 -0
  55. brkraw/resolver/affine.py +539 -0
  56. brkraw/resolver/datatype.py +69 -0
  57. brkraw/resolver/fid.py +90 -0
  58. brkraw/resolver/helpers.py +36 -0
  59. brkraw/resolver/image.py +188 -0
  60. brkraw/resolver/nifti.py +370 -0
  61. brkraw/resolver/shape.py +235 -0
  62. brkraw/schema/__init__.py +3 -0
  63. brkraw/schema/context_map.yaml +62 -0
  64. brkraw/schema/meta.yaml +57 -0
  65. brkraw/schema/niftiheader.yaml +95 -0
  66. brkraw/schema/pruner.yaml +55 -0
  67. brkraw/schema/remapper.yaml +128 -0
  68. brkraw/schema/rules.yaml +154 -0
  69. brkraw/specs/__init__.py +10 -0
  70. brkraw/specs/hook/__init__.py +12 -0
  71. brkraw/specs/hook/logic.py +31 -0
  72. brkraw/specs/hook/validator.py +22 -0
  73. brkraw/specs/meta/__init__.py +5 -0
  74. brkraw/specs/meta/validator.py +156 -0
  75. brkraw/specs/pruner/__init__.py +15 -0
  76. brkraw/specs/pruner/logic.py +361 -0
  77. brkraw/specs/pruner/validator.py +119 -0
  78. brkraw/specs/remapper/__init__.py +27 -0
  79. brkraw/specs/remapper/logic.py +924 -0
  80. brkraw/specs/remapper/validator.py +314 -0
  81. brkraw/specs/rules/__init__.py +6 -0
  82. brkraw/specs/rules/logic.py +263 -0
  83. brkraw/specs/rules/validator.py +103 -0
  84. brkraw-0.5.0.dist-info/METADATA +81 -0
  85. brkraw-0.5.0.dist-info/RECORD +88 -0
  86. {brkraw-0.3.11.dist-info → brkraw-0.5.0.dist-info}/WHEEL +1 -2
  87. brkraw-0.5.0.dist-info/entry_points.txt +13 -0
  88. brkraw/lib/__init__.py +0 -4
  89. brkraw/lib/backup.py +0 -641
  90. brkraw/lib/bids.py +0 -0
  91. brkraw/lib/errors.py +0 -125
  92. brkraw/lib/loader.py +0 -1220
  93. brkraw/lib/orient.py +0 -194
  94. brkraw/lib/parser.py +0 -48
  95. brkraw/lib/pvobj.py +0 -301
  96. brkraw/lib/reference.py +0 -245
  97. brkraw/lib/utils.py +0 -471
  98. brkraw/scripts/__init__.py +0 -0
  99. brkraw/scripts/brk_backup.py +0 -106
  100. brkraw/scripts/brkraw.py +0 -744
  101. brkraw/ui/__init__.py +0 -0
  102. brkraw/ui/config.py +0 -17
  103. brkraw/ui/main_win.py +0 -214
  104. brkraw/ui/previewer.py +0 -225
  105. brkraw/ui/scan_info.py +0 -72
  106. brkraw/ui/scan_list.py +0 -73
  107. brkraw/ui/subj_info.py +0 -128
  108. brkraw-0.3.11.dist-info/METADATA +0 -25
  109. brkraw-0.3.11.dist-info/RECORD +0 -28
  110. brkraw-0.3.11.dist-info/entry_points.txt +0 -3
  111. brkraw-0.3.11.dist-info/top_level.txt +0 -2
  112. tests/__init__.py +0 -0
  113. {brkraw-0.3.11.dist-info → brkraw-0.5.0.dist-info/licenses}/LICENSE +0 -0
brkraw/lib/reference.py DELETED
@@ -1,245 +0,0 @@
1
- # REGEX patterns
2
- ptrn_param = r'^\#\#(?P<key>.*)\=(?P<value>.*)$'
3
- ptrn_key = r'^\$(?P<key>.*)'
4
- ptrn_array = r"\((?P<array>[^()]*)\)"
5
- ptrn_complex_array = r"\((?P<comparray>\(.*)\)$"
6
- ptrn_comment = r'\$\$.*'
7
- ptrn_float = r'^-?\d+\.\d+$'
8
- ptrn_engnotation = r'^-?[0-9.]+e-?[0-9.]+$'
9
- ptrn_integer = r'^[-]*\d+$'
10
- ptrn_string = r'^\<(?P<string>[^>]*)\>$'
11
- ptrn_arraystring = r'\<(?P<string>[^>]*)\>[,]*'
12
- ptrn_bisstring = r'\<(?P<string>\$Bis[^>]*)\#\>'
13
- ptrn_braces = r'\((?P<contents>[^()]*)\)'
14
- # [20210820] Add-paravision 360 related. @[number of repititions]([number]) ex) @5(0)
15
- ptrn_at_array = r'@(\d*)\*\(([-]?\d*[.]?\d*[eE]?[-]?\d*?)\)'
16
-
17
- # Conditional variables
18
- HEADER = 0
19
- PARAMETER = 1
20
-
21
- # Parameters
22
- WORDTYPE = \
23
- dict(_32BIT_SGN_INT = 'i',
24
- _16BIT_SGN_INT = 'h',
25
- _8BIT_UNSGN_INT = 'B',
26
- _32BIT_FLOAT = 'f')
27
- BYTEORDER = \
28
- dict(littleEndian = '<',
29
- bigEndian = '>')
30
-
31
- SLICE_ORIENT = {0: {1: 'L->R', 3: 'R->L'},
32
- 1: {1: 'P->A', 3: 'A->P'},
33
- 2: {1: 'F->H', 3: 'F->H'},
34
- }
35
-
36
- ISSUE_REPORT = 'Please report the issue at (https://github.com/dvm-shlee/bruker/issues) with the error message.'
37
-
38
- ERROR_MESSAGES = {'ImportError' : '[{}] is not recognized as ParavisionDataset.',
39
- 'NoSlicePacksDef' : 'NoneType VisuCoreSlicePacksDef.',
40
- 'SliceDistDatatype' : 'unexpected datatype of VisuCoreSliceDist.',
41
- 'SlicePacksSlices' : 'unexpected datatype of VisuCoreSlicePacksSlices',
42
- 'DimType' : 'non compatible dimension type.',
43
- 'NumOrientMatrix' : 'unexpected number of element in VisuCoreOrientation.',
44
- 'NumSlicePosition' : 'unexpected number of element in VisuCorePosition.',
45
- 'PhaseEncDir' : 'unexpected phase encoding direction.',
46
- 'NotIntegrated' : 'not integrated method, please contact developer.'
47
- }
48
-
49
- # BIDS v1.2.2
50
- # Below is the list of METADATA keywords that BIDS recommended
51
- COMMON_METADATA_FIELD = \
52
- dict(Recommended = [ # SCANNER_HARDWARE
53
- 'Manufacturer',
54
- 'ManufacturersModelName',
55
- 'DeviceSerialNumber',
56
- 'StationName',
57
- 'SoftwareVersion',
58
- 'MagneticFieldStrength',
59
- 'ReceiveCoilName',
60
- 'ReceiveCoilActiveElements',
61
- 'GradientSetType',
62
- 'MRTransmitCoilSequence',
63
- 'MatrixCoilMode',
64
- 'CoilCombinationMethod',
65
-
66
- # SEQUENCE_SPECIFIC
67
- 'PulseSequenceType',
68
- 'ScanningSequence',
69
- 'SequenceVariant',
70
- 'ScanOptions',
71
- 'SequenceName',
72
- 'PulseSequenceDetails',
73
- 'NonlinearGradientCorrection',
74
-
75
- # IN_PLANE_SPATIAL_ENCODING
76
- 'NumberShots',
77
- 'ParallelReductionFactorInPlane',
78
- 'ParallelAcquisitionTechnique',
79
- 'PartialFourier',
80
- 'PartialFourierDirection',
81
- 'PhaseEncodingDirection',
82
- 'EffectiveEchoSpacing',
83
- 'TotalReadoutTime',
84
-
85
- # TIMING_PARAMETERS
86
- 'EchoTime',
87
- 'InversionTime',
88
- 'SliceTiming',
89
- 'SliceEncodingDirection',
90
- 'DwellTime',
91
-
92
- # RF_AND_CONTRAST, SLICE_ACCELERATION
93
- 'FlipAngle',
94
- 'MultibandAccerlationFactor',
95
- 'AnatomicalLandmarkCoordinates',
96
-
97
- # INSTITUTION_INFORMATION
98
- 'InstitutionName',
99
- 'InstitutionAddress',
100
- 'InstitutionalDepartmentName'],
101
-
102
- Optional = [ # RF_AND_CONTRAST
103
- 'NegativeContrast',
104
-
105
- # ACQUISITION_SPECIFIC
106
- 'ContrastBolusIngredient'],
107
-
108
- Deprecated = [ # SCANNER_HARDWARE
109
- 'HardcopyDeviceSoftwareVersion'])
110
-
111
- # Matadata Field Mapping for Bruker PvDataset
112
- # BIDS Meta data will be automatically created according to below reference.
113
- # If list is entered as value, each parameter will be tested and the first available value will be returned.
114
- # If dict is entered as value, below condition will be tested.
115
- # If key - where pair: parse value from given key and return index of 'where' from these values
116
- # If key - idx pair: parse value from given key and return value of given 'idx'
117
- # If 'Equation' in key: each key assigned as local variable and test in Equation will be executed to return the value
118
- # Else, new key - value dictionary will be return (for the cases with sub-keys)
119
- # If string is entered as value, The value of given parameter will be parsed from parameter files
120
- COMMON_META_REF = \
121
- dict(Manufacturer = 'VisuManufacturer',
122
- ManufacturersModelName = 'VisuStation',
123
- DeviceSerialNumber = 'VisuSystemOrderNumber',
124
- StationName = 'VisuStation',
125
- SoftwareVersion = 'VisuAcqSoftwareVersion',
126
- MagneticFieldStrength = dict(Freq = 'VisuAcqImagingFrequency',
127
- Equation = 'Freq / 42.576'),
128
- ReceiveCoilName = 'VisuCoilReceiveName',
129
- ReceiveCoilActiveElements = 'VisuCoilReceiveType',
130
- GradientSetType = 'ACQ_status',
131
- MRTransmitCoilSequence = dict(Name = 'VisuCoilTransmitName',
132
- Manufacture = 'VisuCoilTransmitManufacturer',
133
- Type = 'VisuCoilTransmitType'),
134
- CoilConfigName = 'ACQ_coil_config_file', # if Transmit and Receive coil info in None
135
- MatrixCoilMode = 'ACQ_experiment_mode',
136
- CoilCombinationMethod = None,
137
-
138
- # SEQUENCE_SPECIFIC
139
- PulseSequenceType = 'PULPROG', # 'VisuAcqEchoSequenceType'
140
- ScanningSequence = 'VisuAcqSequenceName',
141
- SequenceVariant = 'VisuAcqEchoSequenceType',
142
- ScanOptions = dict(RG = 'VisuRespSynchUsed',
143
- CG = 'VisuCardiacSynchUsed',
144
- PFF = dict(key = 'VisuAcqPartialFourier',
145
- idx = 0),
146
- PFP = dict(key = 'VisuAcqPartialFourier',
147
- idx = 1),
148
- FC = 'VisuAcqFlowCompensation',
149
- SP = 'PVM_FovSatOnOff',
150
- FP = 'VisuAcqSpectralSuppression'),
151
- SequenceName = ['VisuAcquisitionProtocol',
152
- 'ACQ_protocol_name'], # if first component are None
153
- PulseSequenceDetails = 'ACQ_scan_name',
154
- NonlinearGradientCorrection = 'VisuAcqKSpaceTraversal',
155
-
156
- # IN_PLANE_SPATIAL_ENCODING
157
- NumberShots = 'VisuAcqKSpaceTrajectoryCnt',
158
- ParallelReductionFactorInPlane = 'ACQ_phase_factor',
159
- ParallelAcquisitionTechnique = None,
160
- PartialFourier = 'VisuAcqPartialFourier',
161
- PartialFourierDirection = None,
162
- PhaseEncodingDirection = [dict(key = 'VisuAcqGradEncoding',
163
- where = 'phase_enc'),
164
- 'VisuAcqImagePhaseEncDir'], # Deprecated
165
- EffectiveEchoSpacing = dict(BWhzPixel = 'VisuAcqPixelBandwidth',
166
- MatSizePE = dict(key='PVM_EncMatrix',
167
- idx=[dict(key = 'VisuAcqGradEncoding',
168
- where = 'phase_enc'),
169
- 1]), # PV5.1
170
- ACCfactor = 'ACQ_phase_factor',
171
- Equation = '(1 / (MatSizePE * BWhzPixel)) / ACCfactor'), # in second
172
- TotalReadoutTime = dict(ETL = 'VisuAcqEchoTrainLength',
173
- BWhzPixel = 'VisuAcqPixelBandwidth',
174
- ACCfactor = 'ACQ_phase_factor',
175
- Equation = '(1 / BWhzPixel) / ACCfactor'),
176
-
177
- # TIMING_PARAMETERS
178
- EchoTime = dict(TE = 'VisuAcqEchoTime',
179
- Equation = 'np.array(TE)/1000'),
180
- InversionTime = 'VisuAcqInversionTime',
181
- SliceTiming = dict(TR = 'VisuAcqRepetitionTime',
182
- Num_of_Slice = 'VisuCoreFrameCount',
183
- Order = 'ACQ_obj_order',
184
- Equation = 'np.linspace(0, TR/1000, Num_of_Slice + 1)[Order]'),
185
- SliceEncodingDirection = [dict(key = 'VisuAcqGradEncoding',
186
- where = 'slice_enc'),
187
- dict(EncSeq = 'VisuAcqGradEncoding',
188
- Equation = 'len(EncSeq)')],
189
- DwellTime = dict(BWhzPixel ='VisuAcqPixelBandwidth',
190
- Equation ='1/BWhzPixel'),
191
-
192
- # RF_AND_CONTRAST, SLICE_ACCELERATION
193
- FlipAngle = 'VisuAcqFlipAngle',
194
- MultibandAccerlationFactor = None,
195
- AnatomicalLandmarkCoordinates = None,
196
-
197
- # INSTITUTION_INFORMATION
198
- InstitutionName = 'VisuInstitution',
199
- InstitutionAddress = None,
200
- InstitutionalDepartmentName = None)
201
-
202
-
203
- FMRI_META_REF = \
204
- dict(RepetitionTime = dict(TR = 'VisuAcqRepetitionTime',
205
- Equation = 'TR/1000'),
206
- VolumeTiming = dict(TR = 'VisuAcqRepetitionTime',
207
- NR = 'PVM_NRepetitions',
208
- Equation = '(np.arange(NR)*(TR/1000)).tolist()'),
209
- TaskName = None,
210
-
211
- # RECOMMENDED
212
- # - timing parameters
213
- NumberOfVolumesDiscardedByScanner = 'PVM_DummyScans',
214
- NumberOfVolumesDiscardedByUser = None,
215
- DelayTime = None,
216
- AcquisitionDuration = dict(TR = "PVM_ScanTime",
217
- Equation = "TR/1000"),
218
- DelayAfterTrigger = None,
219
-
220
- # - fMRI task information
221
- Instructions = None,
222
- TaskDescription = None,
223
- CogAtlasID = 'https://www.cognitiveatlas.org/fillYourID',
224
- CogPOID = 'http://www.cogpo.org/fillYourID'
225
- )
226
-
227
-
228
- FIELDMAP_META_REF = \
229
- dict(IntendedFor = '',
230
- )
231
-
232
- DATASET_DESC_REF = \
233
- dict(Name='',
234
- BIDSVersion='1.2.2',
235
- License='',
236
- Authors=[''],
237
- Acknowledgements='',
238
- HowToAsknowledge='',
239
- Funding=[''],
240
- EthicApprovals='',
241
- ReferenceAndLinks='',
242
- DatasetDOI='')
243
-
244
- XYZT_UNITS = \
245
- dict(EPI=('mm', 'sec'))