brukerapi 0.1.10__py3-none-any.whl → 0.2.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.
- brukerapi/cli.py +20 -29
- brukerapi/config/properties_fid_core.json +63 -6
- brukerapi/config/properties_rawdata_core.json +16 -9
- brukerapi/config/properties_rawdata_custom.json +65 -1
- brukerapi/data.py +2 -3
- brukerapi/dataset.py +159 -158
- brukerapi/exceptions.py +57 -84
- brukerapi/folders.py +183 -169
- brukerapi/jcampdx.py +221 -235
- brukerapi/mergers.py +15 -22
- brukerapi/schemas.py +218 -278
- brukerapi/splitters.py +94 -81
- brukerapi/utils.py +35 -36
- {brukerapi-0.1.10.dist-info → brukerapi-0.2.0.dist-info}/METADATA +23 -6
- brukerapi-0.2.0.dist-info/RECORD +25 -0
- brukerapi-0.1.10.dist-info/RECORD +0 -25
- {brukerapi-0.1.10.dist-info → brukerapi-0.2.0.dist-info}/WHEEL +0 -0
- {brukerapi-0.1.10.dist-info → brukerapi-0.2.0.dist-info}/entry_points.txt +0 -0
- {brukerapi-0.1.10.dist-info → brukerapi-0.2.0.dist-info}/licenses/LICENSE +0 -0
- {brukerapi-0.1.10.dist-info → brukerapi-0.2.0.dist-info}/top_level.txt +0 -0
brukerapi/splitters.py
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
from .utils import index_to_slice
|
|
2
|
-
from .dataset import Dataset
|
|
3
|
-
|
|
4
|
-
import numpy as np
|
|
5
1
|
import copy
|
|
2
|
+
import os
|
|
6
3
|
from pathlib import Path
|
|
7
4
|
|
|
8
|
-
|
|
5
|
+
import numpy as np
|
|
9
6
|
|
|
7
|
+
from .dataset import Dataset
|
|
8
|
+
from .exceptions import MissingProperty
|
|
9
|
+
from .utils import index_to_slice
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
SUPPORTED_FG = ["FG_ISA", "FG_IRMODE", "FG_ECHO"]
|
|
12
12
|
|
|
13
|
-
def write(self, datasets, path_out=None):
|
|
14
13
|
|
|
14
|
+
class Splitter:
|
|
15
|
+
def write(self, datasets, path_out=None):
|
|
15
16
|
for dataset in datasets:
|
|
16
17
|
if path_out:
|
|
17
|
-
dataset.write(
|
|
18
|
+
dataset.write(f"{Path(path_out)}/{dataset.path.parents[0].name}/{dataset.path.name}")
|
|
18
19
|
else:
|
|
19
20
|
dataset.write(dataset.path)
|
|
20
21
|
|
|
@@ -37,11 +38,11 @@ class Splitter(object):
|
|
|
37
38
|
:param fg_index:
|
|
38
39
|
:return:
|
|
39
40
|
"""
|
|
40
|
-
VisuCoreDataMin = visu_pars[
|
|
41
|
-
value = np.reshape(VisuCoreDataMin.value, dataset.shape_final[dataset.encoded_dim:], order=
|
|
41
|
+
VisuCoreDataMin = visu_pars["VisuCoreDataMin"]
|
|
42
|
+
value = np.reshape(VisuCoreDataMin.value, dataset.shape_final[dataset.encoded_dim :], order="F")
|
|
42
43
|
value = value[index_to_slice(select, value.shape, fg_rel_index)]
|
|
43
|
-
VisuCoreDataMin.size = (np.prod(value.shape),)
|
|
44
|
-
VisuCoreDataMin.value = value.flatten(order=
|
|
44
|
+
VisuCoreDataMin.size = (int(np.prod(value.shape)),)
|
|
45
|
+
VisuCoreDataMin.value = value.flatten(order="F")
|
|
45
46
|
|
|
46
47
|
def _split_VisuCoreDataMax(self, dataset, visu_pars, select, fg_rel_index):
|
|
47
48
|
"""
|
|
@@ -51,11 +52,11 @@ class Splitter(object):
|
|
|
51
52
|
:param fg_index:
|
|
52
53
|
:return:
|
|
53
54
|
"""
|
|
54
|
-
VisuCoreDataMax = visu_pars[
|
|
55
|
-
value = np.reshape(VisuCoreDataMax.value, dataset.shape_final[dataset.encoded_dim:], order=
|
|
55
|
+
VisuCoreDataMax = visu_pars["VisuCoreDataMax"]
|
|
56
|
+
value = np.reshape(VisuCoreDataMax.value, dataset.shape_final[dataset.encoded_dim :], order="F")
|
|
56
57
|
value = value[index_to_slice(select, value.shape, fg_rel_index)]
|
|
57
|
-
VisuCoreDataMax.size = (np.prod(value.shape),)
|
|
58
|
-
VisuCoreDataMax.value = value.flatten(order=
|
|
58
|
+
VisuCoreDataMax.size = (int(np.prod(value.shape)),)
|
|
59
|
+
VisuCoreDataMax.value = value.flatten(order="F")
|
|
59
60
|
|
|
60
61
|
def _split_VisuCoreDataOffs(self, dataset, visu_pars, select, fg_rel_index):
|
|
61
62
|
"""
|
|
@@ -65,11 +66,11 @@ class Splitter(object):
|
|
|
65
66
|
:param fg_index:
|
|
66
67
|
:return:
|
|
67
68
|
"""
|
|
68
|
-
VisuCoreDataOffs = visu_pars[
|
|
69
|
-
value = np.reshape(VisuCoreDataOffs.value, dataset.shape_final[dataset.encoded_dim:],order=
|
|
69
|
+
VisuCoreDataOffs = visu_pars["VisuCoreDataOffs"]
|
|
70
|
+
value = np.reshape(VisuCoreDataOffs.value, dataset.shape_final[dataset.encoded_dim :], order="F")
|
|
70
71
|
value = value[index_to_slice(select, value.shape, fg_rel_index)]
|
|
71
|
-
VisuCoreDataOffs.size = (np.prod(value.shape),)
|
|
72
|
-
VisuCoreDataOffs.value = value.flatten(order=
|
|
72
|
+
VisuCoreDataOffs.size = (int(np.prod(value.shape)),)
|
|
73
|
+
VisuCoreDataOffs.value = value.flatten(order="F")
|
|
73
74
|
|
|
74
75
|
def _split_VisuCoreDataSlope(self, dataset, visu_pars, select, fg_rel_index):
|
|
75
76
|
"""
|
|
@@ -79,34 +80,34 @@ class Splitter(object):
|
|
|
79
80
|
:param fg_index:
|
|
80
81
|
:return:
|
|
81
82
|
"""
|
|
82
|
-
VisuCoreDataSlope = visu_pars[
|
|
83
|
-
value = np.reshape(VisuCoreDataSlope.value, dataset.shape_final[dataset.encoded_dim:],order=
|
|
83
|
+
VisuCoreDataSlope = visu_pars["VisuCoreDataSlope"]
|
|
84
|
+
value = np.reshape(VisuCoreDataSlope.value, dataset.shape_final[dataset.encoded_dim :], order="F")
|
|
84
85
|
value = value[index_to_slice(select, value.shape, fg_rel_index)]
|
|
85
|
-
VisuCoreDataSlope.size = (np.prod(value.shape),)
|
|
86
|
-
VisuCoreDataSlope.value = value.flatten(order=
|
|
86
|
+
VisuCoreDataSlope.size = (int(np.prod(value.shape)),)
|
|
87
|
+
VisuCoreDataSlope.value = value.flatten(order="F")
|
|
87
88
|
|
|
88
89
|
def _split_VisuCoreTransposition(self, dataset, visu_pars, index, fg_index):
|
|
89
90
|
try:
|
|
90
|
-
VisuCoreTransposition = visu_pars[
|
|
91
|
+
VisuCoreTransposition = visu_pars["VisuCoreTransposition"]
|
|
91
92
|
except KeyError:
|
|
92
93
|
return VisuCoreTransposition
|
|
93
94
|
|
|
94
|
-
value = np.reshape(VisuCoreTransposition.value, dataset.shape_final[dataset.encoded_dim:], order=
|
|
95
|
+
value = np.reshape(VisuCoreTransposition.value, dataset.shape_final[dataset.encoded_dim :], order="F")
|
|
95
96
|
value = value[index_to_slice(index, value.shape, fg_index - dataset.encoded_dim)]
|
|
96
|
-
VisuCoreTransposition.size = (np.prod(value.shape),)
|
|
97
|
-
VisuCoreTransposition.value = value.flatten(order=
|
|
97
|
+
VisuCoreTransposition.size = (int(np.prod(value.shape)),)
|
|
98
|
+
VisuCoreTransposition.value = value.flatten(order="F")
|
|
99
|
+
return None
|
|
98
100
|
|
|
99
101
|
|
|
100
102
|
class FrameGroupSplitter(Splitter):
|
|
101
103
|
def __init__(self, fg):
|
|
102
104
|
if fg not in SUPPORTED_FG:
|
|
103
|
-
raise
|
|
105
|
+
raise NotImplementedError(f"Split operation for {fg} is not implemented")
|
|
104
106
|
|
|
105
|
-
super(
|
|
107
|
+
super().__init__()
|
|
106
108
|
self.fg = fg
|
|
107
109
|
|
|
108
|
-
|
|
109
|
-
def split(self, dataset, select=None, write=False, path_out=None, **kwargs):
|
|
110
|
+
def split(self, dataset, select=None, write=None, path_out=None, **kwargs):
|
|
110
111
|
"""Split Bruker object along a dimension of specific frame group.
|
|
111
112
|
Only the frame groups listed in SPLIT_FG_IMPLEMENTED can be used to split the object.
|
|
112
113
|
|
|
@@ -121,14 +122,17 @@ class FrameGroupSplitter(Splitter):
|
|
|
121
122
|
|
|
122
123
|
"""
|
|
123
124
|
|
|
124
|
-
if
|
|
125
|
-
|
|
125
|
+
if write is None:
|
|
126
|
+
write = False
|
|
127
|
+
|
|
128
|
+
if f"<{self.fg}>" not in dataset.dim_type:
|
|
129
|
+
raise ValueError(f"Dataset does not contain {self.fg} frame group")
|
|
126
130
|
|
|
127
131
|
"""
|
|
128
132
|
CHECK if FG and index are valid
|
|
129
133
|
"""
|
|
130
134
|
# absolute index of FG_SLICE among dimensions of the dataset
|
|
131
|
-
fg_abs_index = dataset.dim_type.index("<{}>"
|
|
135
|
+
fg_abs_index = dataset.dim_type.index(f"<{self.fg}>")
|
|
132
136
|
|
|
133
137
|
# index of FG_SLICE among frame group dimensions of the dataset
|
|
134
138
|
fg_rel_index = fg_abs_index - dataset.encoded_dim
|
|
@@ -141,10 +145,12 @@ class FrameGroupSplitter(Splitter):
|
|
|
141
145
|
select = list(range(0, fg_size))
|
|
142
146
|
|
|
143
147
|
if isinstance(select, int):
|
|
144
|
-
select = [
|
|
148
|
+
select = [
|
|
149
|
+
select,
|
|
150
|
+
]
|
|
145
151
|
|
|
146
152
|
if max(select) >= fg_size:
|
|
147
|
-
raise IndexError(f
|
|
153
|
+
raise IndexError(f"Selection {select} out of bounds, size of {self.fg} dimension is {fg_size}")
|
|
148
154
|
|
|
149
155
|
"""
|
|
150
156
|
PERFORM splitting
|
|
@@ -153,10 +159,13 @@ class FrameGroupSplitter(Splitter):
|
|
|
153
159
|
|
|
154
160
|
for select_ in select:
|
|
155
161
|
# construct a new Dataset, without loading data, the data will be supplied later
|
|
156
|
-
name =
|
|
162
|
+
name = f"{dataset.path.parents[0].name}_{self.fg}_{select_}/2dseq"
|
|
163
|
+
|
|
164
|
+
dset_path = dataset.path.parents[1] / name
|
|
165
|
+
os.makedirs(dset_path, exist_ok=True)
|
|
157
166
|
|
|
158
167
|
# construct a new Dataset, without loading data, the data will be supplied later
|
|
159
|
-
dataset_ = Dataset(dataset.path.parents[1] / name, load=
|
|
168
|
+
dataset_ = Dataset(dataset.path.parents[1] / name, load=0)
|
|
160
169
|
|
|
161
170
|
dataset_.parameters = self._split_params(dataset, select_, fg_abs_index, fg_rel_index, fg_size)
|
|
162
171
|
|
|
@@ -178,8 +187,7 @@ class FrameGroupSplitter(Splitter):
|
|
|
178
187
|
return datasets
|
|
179
188
|
|
|
180
189
|
def _split_params(self, dataset, select, fg_abs_index, fg_rel_index, fg_size):
|
|
181
|
-
|
|
182
|
-
visu_pars = copy.deepcopy(dataset.parameters['visu_pars'])
|
|
190
|
+
visu_pars = copy.deepcopy(dataset.parameters["visu_pars"])
|
|
183
191
|
|
|
184
192
|
self._split_VisuCoreFrameCount(visu_pars, fg_size)
|
|
185
193
|
self._split_VisuFGOrderDescDim(visu_pars)
|
|
@@ -189,12 +197,12 @@ class FrameGroupSplitter(Splitter):
|
|
|
189
197
|
self._split_VisuCoreDataMin(dataset, visu_pars, select, fg_rel_index)
|
|
190
198
|
self._split_VisuCoreDataMax(dataset, visu_pars, select, fg_rel_index)
|
|
191
199
|
|
|
192
|
-
if self.fg ==
|
|
200
|
+
if self.fg == "FG_ECHO":
|
|
193
201
|
self._split_params_FG_ECHO(dataset, select, fg_abs_index, fg_rel_index, fg_size, visu_pars)
|
|
194
|
-
if self.fg ==
|
|
202
|
+
if self.fg == "FG_ISA":
|
|
195
203
|
self._split_params_FG_ISA(dataset, select, fg_abs_index, fg_rel_index, fg_size, visu_pars)
|
|
196
204
|
|
|
197
|
-
return {
|
|
205
|
+
return {"visu_pars": visu_pars}
|
|
198
206
|
|
|
199
207
|
def _split_params_FG_ISA(self, dataset, select, fg_abs_index, fg_rel_index, fg_size, visu_pars):
|
|
200
208
|
self._split_VisuCoreDataUnits(visu_pars, dataset, select, fg_rel_index)
|
|
@@ -204,43 +212,42 @@ class FrameGroupSplitter(Splitter):
|
|
|
204
212
|
self._split_VisuAcqEchoTime(visu_pars, select)
|
|
205
213
|
|
|
206
214
|
def _split_VisuCoreFrameCount(self, visu_pars, fg_size):
|
|
207
|
-
VisuCoreFrameCount = visu_pars[
|
|
215
|
+
VisuCoreFrameCount = visu_pars["VisuCoreFrameCount"]
|
|
208
216
|
value = int(VisuCoreFrameCount.value / fg_size)
|
|
209
217
|
VisuCoreFrameCount.value = value
|
|
210
218
|
|
|
211
219
|
def _split_VisuFGOrderDescDim(self, visu_pars):
|
|
212
|
-
VisuFGOrderDescDim = visu_pars[
|
|
220
|
+
VisuFGOrderDescDim = visu_pars["VisuFGOrderDescDim"]
|
|
213
221
|
value = VisuFGOrderDescDim.value - 1
|
|
214
222
|
|
|
215
223
|
if value > 1:
|
|
216
224
|
VisuFGOrderDescDim.value = value
|
|
217
225
|
else:
|
|
218
|
-
del visu_pars[
|
|
226
|
+
del visu_pars["VisuFGOrderDescDim"]
|
|
219
227
|
|
|
220
228
|
def _split_VisuCoreDataUnits(self, visu_pars, fg_scheme, index, fg_index):
|
|
221
|
-
VisuCoreDataUnits = visu_pars[
|
|
229
|
+
VisuCoreDataUnits = visu_pars["VisuCoreDataUnits"]
|
|
222
230
|
value = VisuCoreDataUnits.value
|
|
223
231
|
VisuCoreDataUnits.value = value[index]
|
|
224
232
|
VisuCoreDataUnits.size = (65,)
|
|
225
233
|
|
|
226
234
|
def _split_VisuFGOrderDesc(self, visu_pars, fg):
|
|
227
|
-
VisuFGOrderDesc = visu_pars[
|
|
235
|
+
VisuFGOrderDesc = visu_pars["VisuFGOrderDesc"]
|
|
228
236
|
|
|
229
237
|
size = VisuFGOrderDesc.size[0] - 1
|
|
230
238
|
VisuFGOrderDesc.size = size
|
|
231
239
|
|
|
232
240
|
value = VisuFGOrderDesc.nested
|
|
233
241
|
for fg_ in value:
|
|
234
|
-
if fg_[1] ==
|
|
242
|
+
if fg_[1] == f"<{fg}>":
|
|
235
243
|
value.remove(fg_)
|
|
236
244
|
if value:
|
|
237
245
|
VisuFGOrderDesc.value = value
|
|
238
246
|
else:
|
|
239
|
-
del visu_pars[
|
|
247
|
+
del visu_pars["VisuFGOrderDesc"]
|
|
240
248
|
|
|
241
249
|
def _split_VisuFGElemComment(self, visu_pars, fg_scheme, index, fg_index):
|
|
242
|
-
|
|
243
|
-
VisuFGElemComment = visu_pars['VisuFGElemComment']
|
|
250
|
+
VisuFGElemComment = visu_pars["VisuFGElemComment"]
|
|
244
251
|
|
|
245
252
|
value = VisuFGElemComment.value
|
|
246
253
|
|
|
@@ -249,9 +256,9 @@ class FrameGroupSplitter(Splitter):
|
|
|
249
256
|
VisuFGElemComment.size = (65,)
|
|
250
257
|
|
|
251
258
|
def _split_VisuAcqEchoTime(self, visu_pars, select):
|
|
252
|
-
VisuAcqEchoTime = visu_pars[
|
|
253
|
-
value = VisuAcqEchoTime.
|
|
254
|
-
VisuAcqEchoTime.size=(1,)
|
|
259
|
+
VisuAcqEchoTime = visu_pars["VisuAcqEchoTime"]
|
|
260
|
+
value = VisuAcqEchoTime.list
|
|
261
|
+
VisuAcqEchoTime.size = (1,)
|
|
255
262
|
VisuAcqEchoTime.value = float(value[select])
|
|
256
263
|
|
|
257
264
|
|
|
@@ -259,7 +266,8 @@ class SlicePackageSplitter(Splitter):
|
|
|
259
266
|
"""
|
|
260
267
|
Split 2dseq data set along individual slice packages
|
|
261
268
|
"""
|
|
262
|
-
|
|
269
|
+
|
|
270
|
+
def split(self, dataset, write=None, path_out=None):
|
|
263
271
|
"""
|
|
264
272
|
Split 2dseq data set containing multiple data sets into a list of 2dseq data sets containing individual slice packages.
|
|
265
273
|
|
|
@@ -271,19 +279,22 @@ class SlicePackageSplitter(Splitter):
|
|
|
271
279
|
:return: list of split data sets
|
|
272
280
|
"""
|
|
273
281
|
|
|
282
|
+
if write is None:
|
|
283
|
+
write = False
|
|
284
|
+
|
|
274
285
|
try:
|
|
275
|
-
VisuCoreSlicePacksSlices = dataset[
|
|
286
|
+
VisuCoreSlicePacksSlices = dataset["VisuCoreSlicePacksSlices"].nested
|
|
276
287
|
except KeyError:
|
|
277
|
-
|
|
288
|
+
raise MissingProperty("Parameter VisuCoreSlicePacksSlices not found") from KeyError
|
|
278
289
|
|
|
279
290
|
# list of split data sets
|
|
280
291
|
datasets = []
|
|
281
292
|
|
|
282
293
|
# range of frames of given slice package
|
|
283
|
-
frame_range = range(0,0)
|
|
294
|
+
frame_range = range(0, 0)
|
|
284
295
|
|
|
285
296
|
# absolute index of FG_SLICE among dimensions of the dataset
|
|
286
|
-
fg_rel_index = dataset[
|
|
297
|
+
fg_rel_index = dataset["VisuFGOrderDesc"].sub_list(1).index("<FG_SLICE>")
|
|
287
298
|
|
|
288
299
|
# index of FG_SLICE among frame group dimensions of the dataset
|
|
289
300
|
fg_abs_index = fg_rel_index + dataset.encoded_dim
|
|
@@ -291,17 +302,18 @@ class SlicePackageSplitter(Splitter):
|
|
|
291
302
|
# slice package split loop
|
|
292
303
|
for sp_index in range(len(VisuCoreSlicePacksSlices)):
|
|
293
304
|
# set range
|
|
294
|
-
frame_range= range(frame_range.stop, frame_range.stop + VisuCoreSlicePacksSlices[sp_index][1])
|
|
305
|
+
frame_range = range(frame_range.stop, frame_range.stop + VisuCoreSlicePacksSlices[sp_index][1])
|
|
295
306
|
|
|
296
307
|
# number of frames contained in given slice package
|
|
297
308
|
frame_count = frame_range.stop - frame_range.start
|
|
298
309
|
|
|
299
310
|
# name of the data set created by the split
|
|
300
|
-
name =
|
|
311
|
+
name = f"{dataset.path.parents[0].name}_sp_{sp_index}/2dseq"
|
|
301
312
|
|
|
313
|
+
os.makedirs(dataset.path.parents[1] / name, exist_ok=True)
|
|
302
314
|
|
|
303
315
|
# construct a new Dataset, without loading data, the data will be supplied later
|
|
304
|
-
dataset_ = Dataset(dataset.path.parents[1] / name, load=
|
|
316
|
+
dataset_ = Dataset(dataset.path.parents[1] / name, load=0)
|
|
305
317
|
|
|
306
318
|
# SPLIT parameters
|
|
307
319
|
dataset_.parameters = self._split_parameters(dataset, frame_range, fg_rel_index, fg_abs_index, sp_index, frame_count)
|
|
@@ -310,12 +322,12 @@ class SlicePackageSplitter(Splitter):
|
|
|
310
322
|
dataset_.load_properties()
|
|
311
323
|
|
|
312
324
|
# change id
|
|
313
|
-
dataset_.id =
|
|
325
|
+
dataset_.id = f"{dataset_.id}_sp_{sp_index}"
|
|
314
326
|
|
|
315
327
|
# construct schema
|
|
316
328
|
dataset_.load_schema()
|
|
317
329
|
|
|
318
|
-
#SPLIT data
|
|
330
|
+
# SPLIT data
|
|
319
331
|
dataset_.data = self._split_data(dataset, frame_range, fg_abs_index)
|
|
320
332
|
|
|
321
333
|
# append to result
|
|
@@ -328,7 +340,7 @@ class SlicePackageSplitter(Splitter):
|
|
|
328
340
|
|
|
329
341
|
def _split_parameters(self, dataset, frame_range, fg_rel_index, fg_abs_index, sp_index, frame_count):
|
|
330
342
|
# create a copy of visu_pars of the original data set
|
|
331
|
-
visu_pars_ = copy.deepcopy(dataset.parameters[
|
|
343
|
+
visu_pars_ = copy.deepcopy(dataset.parameters["visu_pars"])
|
|
332
344
|
|
|
333
345
|
# modify individual parameters so that the resulting data set is consistent
|
|
334
346
|
self._split_VisuCorePosition(visu_pars_, frame_range, frame_count)
|
|
@@ -337,37 +349,38 @@ class SlicePackageSplitter(Splitter):
|
|
|
337
349
|
self._split_VisuCoreDataMax(dataset, visu_pars_, frame_range, fg_rel_index)
|
|
338
350
|
self._split_VisuCoreDataOffs(dataset, visu_pars_, frame_range, fg_rel_index)
|
|
339
351
|
self._split_VisuCoreDataSlope(dataset, visu_pars_, frame_range, fg_rel_index)
|
|
340
|
-
|
|
352
|
+
if "VisuCoreTransposition" in dataset:
|
|
353
|
+
self._split_VisuCoreTransposition(dataset, visu_pars_, frame_range, fg_rel_index)
|
|
341
354
|
self._split_VisuCoreFrameCount(dataset, visu_pars_, frame_count, fg_abs_index)
|
|
342
355
|
self._split_VisuFGOrderDesc(visu_pars_, fg_rel_index, frame_count)
|
|
343
356
|
self._split_VisuCoreSlicePacksDef(visu_pars_)
|
|
344
357
|
self._split_VisuCoreSlicePacksSlices(visu_pars_, sp_index)
|
|
345
358
|
self._split_VisuCoreSlicePacksSliceDist(visu_pars_, sp_index)
|
|
346
359
|
|
|
347
|
-
return {"visu_pars":visu_pars_}
|
|
360
|
+
return {"visu_pars": visu_pars_}
|
|
348
361
|
|
|
349
362
|
def _split_VisuCoreFrameCount(self, dataset, visu_pars, frame_count, fg_ind_abs):
|
|
350
|
-
VisuCoreFrameCount = visu_pars[
|
|
363
|
+
VisuCoreFrameCount = visu_pars["VisuCoreFrameCount"]
|
|
351
364
|
|
|
352
365
|
layout = np.array(dataset.shape_final)
|
|
353
|
-
layout[0:dataset.encoded_dim] = 1
|
|
366
|
+
layout[0 : dataset.encoded_dim] = 1
|
|
354
367
|
layout[fg_ind_abs] = 1
|
|
355
368
|
frames = int(frame_count * np.prod(layout))
|
|
356
369
|
|
|
357
370
|
VisuCoreFrameCount.value = frames
|
|
358
371
|
|
|
359
372
|
def _split_VisuCoreOrientation(self, visu_pars, frame_range, frame_count):
|
|
360
|
-
VisuCoreOrientation = visu_pars[
|
|
361
|
-
VisuCoreOrientation.value = VisuCoreOrientation.value[frame_range, :].flatten(order=
|
|
373
|
+
VisuCoreOrientation = visu_pars["VisuCoreOrientation"]
|
|
374
|
+
VisuCoreOrientation.value = VisuCoreOrientation.value[frame_range, :].flatten(order="C")
|
|
362
375
|
VisuCoreOrientation.size = (frame_count, 9)
|
|
363
376
|
|
|
364
377
|
def _split_VisuCorePosition(self, visu_pars, frame_range, frame_count):
|
|
365
|
-
VisuCorePosition = visu_pars[
|
|
366
|
-
VisuCorePosition.value = VisuCorePosition.value[frame_range, :].flatten(order=
|
|
378
|
+
VisuCorePosition = visu_pars["VisuCorePosition"]
|
|
379
|
+
VisuCorePosition.value = VisuCorePosition.value[frame_range, :].flatten(order="C")
|
|
367
380
|
VisuCorePosition.size = (frame_count, 3)
|
|
368
381
|
|
|
369
382
|
def _split_VisuFGOrderDesc(self, visu_pars, fg_rel_ind, frame_count):
|
|
370
|
-
VisuFGOrderDesc = visu_pars[
|
|
383
|
+
VisuFGOrderDesc = visu_pars["VisuFGOrderDesc"]
|
|
371
384
|
value = VisuFGOrderDesc.value
|
|
372
385
|
|
|
373
386
|
if isinstance(value[fg_rel_ind], list):
|
|
@@ -377,18 +390,18 @@ class SlicePackageSplitter(Splitter):
|
|
|
377
390
|
|
|
378
391
|
VisuFGOrderDesc.value = value
|
|
379
392
|
|
|
380
|
-
def _split_VisuCoreSlicePacksDef(self,visu_pars):
|
|
381
|
-
VisuCoreSlicePacksDef = visu_pars[
|
|
393
|
+
def _split_VisuCoreSlicePacksDef(self, visu_pars):
|
|
394
|
+
VisuCoreSlicePacksDef = visu_pars["VisuCoreSlicePacksDef"]
|
|
382
395
|
value = VisuCoreSlicePacksDef.value
|
|
383
396
|
value[1] = 1
|
|
384
397
|
VisuCoreSlicePacksDef.value = value
|
|
385
398
|
|
|
386
399
|
def _split_VisuCoreSlicePacksSlices(self, visu_pars_, sp_index):
|
|
387
|
-
VisuCoreSlicePacksSlices = visu_pars_[
|
|
400
|
+
VisuCoreSlicePacksSlices = visu_pars_["VisuCoreSlicePacksSlices"]
|
|
388
401
|
VisuCoreSlicePacksSlices.value = [VisuCoreSlicePacksSlices.value[sp_index]]
|
|
389
402
|
|
|
390
403
|
def _split_VisuCoreSlicePacksSliceDist(self, visu_pars_, sp_index):
|
|
391
|
-
VisuCoreSlicePacksSliceDist = visu_pars_[
|
|
392
|
-
value = int(VisuCoreSlicePacksSliceDist.
|
|
404
|
+
VisuCoreSlicePacksSliceDist = visu_pars_["VisuCoreSlicePacksSliceDist"]
|
|
405
|
+
value = int(VisuCoreSlicePacksSliceDist.array[sp_index])
|
|
393
406
|
VisuCoreSlicePacksSliceDist.value = value
|
|
394
407
|
VisuCoreSlicePacksSliceDist.size = 1
|
brukerapi/utils.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import numpy as np
|
|
2
2
|
|
|
3
|
+
|
|
3
4
|
def index_to_slice(index, data_shape, dim_index):
|
|
4
5
|
out = []
|
|
5
6
|
|
|
6
7
|
if isinstance(index, range):
|
|
7
8
|
index = slice(index.start, index.stop)
|
|
8
9
|
|
|
9
|
-
|
|
10
10
|
for i in range(len(data_shape)):
|
|
11
11
|
if i != dim_index:
|
|
12
12
|
out.append(slice(0, data_shape[i]))
|
|
@@ -15,48 +15,47 @@ def index_to_slice(index, data_shape, dim_index):
|
|
|
15
15
|
|
|
16
16
|
return tuple(out)
|
|
17
17
|
|
|
18
|
+
|
|
18
19
|
def simple_measurement(dataset):
|
|
20
|
+
if dataset.encoded_dim == 1:
|
|
21
|
+
axes = (0,)
|
|
22
|
+
elif dataset.encoded_dim == 2:
|
|
23
|
+
axes = (0, 1)
|
|
24
|
+
elif dataset.encoded_dim == 3:
|
|
25
|
+
axes = (0, 1, 2)
|
|
19
26
|
|
|
20
|
-
|
|
21
|
-
axes = (0,)
|
|
22
|
-
elif dataset.encoded_dim == 2:
|
|
23
|
-
axes = (0,1)
|
|
24
|
-
elif dataset.encoded_dim == 3:
|
|
25
|
-
axes = (0,1,2)
|
|
27
|
+
return np.fft.fftshift(np.fft.fft2(dataset.data, axes=axes), axes=axes)
|
|
26
28
|
|
|
27
|
-
return np.fft.fftshift(np.fft.fft2(dataset.data,axes=axes),axes=axes)
|
|
28
29
|
|
|
29
30
|
def simple_reconstruction(dataset, **kwargs):
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
data = np.fft.fftshift(np.fft.ifft2(dataset.data, axes=axes),
|
|
42
|
-
axes=axes)
|
|
43
|
-
|
|
44
|
-
if kwargs.get("COMBINE_CHANNELS") is True:
|
|
45
|
-
return combine_channels(data=data)
|
|
46
|
-
else:
|
|
47
|
-
return data
|
|
31
|
+
"""
|
|
32
|
+
Simple Fourier reconstruction
|
|
33
|
+
:return: image
|
|
34
|
+
"""
|
|
35
|
+
if dataset.encoded_dim == 1:
|
|
36
|
+
axes = (0,)
|
|
37
|
+
elif dataset.encoded_dim == 2:
|
|
38
|
+
axes = (0, 1)
|
|
39
|
+
elif dataset.encoded_dim == 3:
|
|
40
|
+
axes = (0, 1, 2)
|
|
48
41
|
|
|
49
|
-
|
|
42
|
+
data = np.fft.fftshift(np.fft.ifft2(dataset.data, axes=axes), axes=axes)
|
|
50
43
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
44
|
+
if kwargs.get("COMBINE_CHANNELS") is True:
|
|
45
|
+
return combine_channels(data=data)
|
|
46
|
+
return data
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def combine_channels(dataset, data=None):
|
|
50
|
+
if dataset.scheme is not None:
|
|
51
|
+
channel_dim = dataset.scheme.dim_type.index("channel")
|
|
52
|
+
else:
|
|
53
|
+
raise NotImplementedError
|
|
55
54
|
|
|
56
|
-
|
|
57
|
-
|
|
55
|
+
if data is None:
|
|
56
|
+
data = dataset.data
|
|
58
57
|
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
data = data**2
|
|
59
|
+
data = np.expand_dims(np.sum(data, channel_dim), channel_dim)
|
|
61
60
|
|
|
62
|
-
|
|
61
|
+
return np.sqrt(data)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: brukerapi
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Bruker API
|
|
5
|
-
Author-email: Tomas Psorn <tomaspsorn@isibrno.cz>
|
|
5
|
+
Author-email: Tomas Psorn <tomaspsorn@isibrno.cz>, Jiri Vitous <vitous@isibrno.cz>
|
|
6
6
|
License: MIT
|
|
7
7
|
Project-URL: Homepage, https://github.com/isi-nmr/brukerapi-python
|
|
8
8
|
Project-URL: Download, https://github.com/isi-nmr/brukerapi-python/releases/latest
|
|
@@ -15,6 +15,8 @@ Requires-Dist: pyyaml
|
|
|
15
15
|
Provides-Extra: dev
|
|
16
16
|
Requires-Dist: pytest; extra == "dev"
|
|
17
17
|
Requires-Dist: zenodo_get; extra == "dev"
|
|
18
|
+
Requires-Dist: ruff; extra == "dev"
|
|
19
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
18
20
|
Dynamic: license-file
|
|
19
21
|
|
|
20
22
|
brukerapi-python
|
|
@@ -30,6 +32,7 @@ brukerapi-python
|
|
|
30
32
|
:target: https://bruker-api.readthedocs.io/en/latest/?badge=latest
|
|
31
33
|
:alt: Documentation Status
|
|
32
34
|
|
|
35
|
+
|
|
33
36
|
A Python package providing I/O interface for Bruker data sets.
|
|
34
37
|
|
|
35
38
|
tl;dr
|
|
@@ -70,6 +73,18 @@ Load an entire **study**:
|
|
|
70
73
|
dataset.data # access data array
|
|
71
74
|
dataset.VisuCoreSize # get a value of a single parameter
|
|
72
75
|
|
|
76
|
+
Load a parametric file:
|
|
77
|
+
|
|
78
|
+
.. code-block:: python
|
|
79
|
+
|
|
80
|
+
from brukerapi.jcampdx import JCAMPDX
|
|
81
|
+
|
|
82
|
+
parameters = JCAMPDX('path_to_scan/method')
|
|
83
|
+
|
|
84
|
+
TR = data.params["PVM_RepetitionTime"].value # This way
|
|
85
|
+
TR = data.get_value("PVM_RepetitionTime") # Or this way
|
|
86
|
+
|
|
87
|
+
|
|
73
88
|
|
|
74
89
|
|
|
75
90
|
|
|
@@ -170,8 +185,8 @@ Compatible pulse sequences for **fid** data sets:
|
|
|
170
185
|
* STEAM.ppg
|
|
171
186
|
* igFLASH.ppg
|
|
172
187
|
|
|
173
|
-
ParaVision v6.0.1
|
|
174
|
-
"""""""""""""""""
|
|
188
|
+
ParaVision v6.0.1 and v7.0.0
|
|
189
|
+
"""""""""""""""""""""""""""""""
|
|
175
190
|
Compatible data set types:
|
|
176
191
|
|
|
177
192
|
* **fid**
|
|
@@ -217,8 +232,10 @@ Compatible pulse sequences for **fid** data sets:
|
|
|
217
232
|
* CPMG.ppg
|
|
218
233
|
* RfProfile.ppg
|
|
219
234
|
|
|
220
|
-
|
|
221
|
-
|
|
235
|
+
|
|
236
|
+
ParaVision 360 v1.1 v3.0-v3.7
|
|
237
|
+
"""""""""""""""""""""""""""""""""
|
|
238
|
+
Reading rawdata is supported only in a basic form, no reshaping into k-space is supported at the moment.
|
|
222
239
|
Compatible data set types:
|
|
223
240
|
|
|
224
241
|
* **2dseq**
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
brukerapi/__init__.py,sha256=lT95qTFTZoyKk5vKYR3lPIdoLY6y4r8eOJcbk_wTy0g,83
|
|
2
|
+
brukerapi/cli.py,sha256=Vkl8ZL2_8WGh1gv9AGY54Y0TP7MNX7Sf9RwQOKrcGnY,4158
|
|
3
|
+
brukerapi/data.py,sha256=qvILBKRbQf2DEZRpnySuOa8dRkXBEhizDJkFvRxZPKg,201
|
|
4
|
+
brukerapi/dataset.py,sha256=obd_zc9KZOhYe7DQbGSLXGaBwuGoi4NWXNocS3kSJf8,25251
|
|
5
|
+
brukerapi/exceptions.py,sha256=qsXzJLZn1mdypN8TltX4fUPgCxCDWWFaVpEPlBkDRE4,8501
|
|
6
|
+
brukerapi/folders.py,sha256=pJ7HOfp4aEl01pDRYJdiRaLljzbpbQbxkhgntBpFltg,17798
|
|
7
|
+
brukerapi/jcampdx.py,sha256=SqT9AE_qxezlKnM2hfHTIFZXusO-UgezNJeVqKwayAY,25392
|
|
8
|
+
brukerapi/mergers.py,sha256=Kt3gzE64fzgexi6DGIxSDjA6Bsrpv3E_Kvw2K5AA4Es,3944
|
|
9
|
+
brukerapi/schemas.py,sha256=R_W1BkeLT56Jsu9MmSKszOPhBcsIPPXy3B45j-PrDaU,24623
|
|
10
|
+
brukerapi/splitters.py,sha256=Z276unmCOL6YIbRrUP1QKU49QiTq3_7U7GbnZQt_Qug,15793
|
|
11
|
+
brukerapi/utils.py,sha256=Auuj_RyBKxjG7jNKOKngeJyp95bFvAPk_4aYnR_Wbms,1447
|
|
12
|
+
brukerapi/config/properties_2dseq_core.json,sha256=3JlQyDWhRiczFhLTXR0NS1OIxWwRljDBRvwlBtUnsfg,3919
|
|
13
|
+
brukerapi/config/properties_2dseq_custom.json,sha256=Kxic-Asg2am-vFtFHaHN_lxZdA8VEBUXlVeSPLbWLBw,9282
|
|
14
|
+
brukerapi/config/properties_fid_core.json,sha256=cxFIbb37lzl4oKTTg6226hv9ul3ClBMAUJcYxoTszow,17236
|
|
15
|
+
brukerapi/config/properties_fid_custom.json,sha256=QIN3fryEbuV236D9GIOPmNkBYiKNXMByjTS4uubCmUM,1347
|
|
16
|
+
brukerapi/config/properties_rawdata_core.json,sha256=wF2uDSUtM_fOep-grs6Jy46giGHTEwIkkFHykLFcrMI,3028
|
|
17
|
+
brukerapi/config/properties_rawdata_custom.json,sha256=hNA4yuvxYua57PHDINGic3bDWft1VpIu1D0JSeXn6V4,833
|
|
18
|
+
brukerapi/config/properties_traj_core.json,sha256=zx2gnPkVj9fUAL1iwixrtoRV7BlJpVTSYA4I-7s9Mzc,1956
|
|
19
|
+
brukerapi/config/properties_traj_custom.json,sha256=-KWibjBW62-wbe6z28z9iK50kAIAyYxwtZZru37J1N4,4
|
|
20
|
+
brukerapi-0.2.0.dist-info/licenses/LICENSE,sha256=qrKdH1kPjQsHQZxAS6dOSoPKyhrI0nKtNFVhG-fjDJw,1064
|
|
21
|
+
brukerapi-0.2.0.dist-info/METADATA,sha256=Pnpr54WUISHauMVmpPLXTDMIazdaexueMmHl7ezjZcE,5853
|
|
22
|
+
brukerapi-0.2.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
23
|
+
brukerapi-0.2.0.dist-info/entry_points.txt,sha256=GkMTo84oMksVEhkrItYbnegKXFu0jyQHfOAvAn8z-Wo,46
|
|
24
|
+
brukerapi-0.2.0.dist-info/top_level.txt,sha256=32V6nLorM2P3LQY_gPPKEgDbeTF0N-HCAyUeEUsf2GU,10
|
|
25
|
+
brukerapi-0.2.0.dist-info/RECORD,,
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
brukerapi/__init__.py,sha256=lT95qTFTZoyKk5vKYR3lPIdoLY6y4r8eOJcbk_wTy0g,83
|
|
2
|
-
brukerapi/cli.py,sha256=eHvbg7JHCRgS9LO8nkKplMu9q3ZDj03uvSGsqLZ4H0g,4167
|
|
3
|
-
brukerapi/data.py,sha256=qdG404FHfWqk2g59E1qmtGpEghTKWcavt_kzvbo2WN8,203
|
|
4
|
-
brukerapi/dataset.py,sha256=otp-8N3n4HZc6IHp86PQ_2qXlPt3vzCdLiDYo3BviNk,25049
|
|
5
|
-
brukerapi/exceptions.py,sha256=XHX6vtjPCqNMConAbT0IDjdiTIhHZe8kqjL12eBJ0Fg,9234
|
|
6
|
-
brukerapi/folders.py,sha256=4JvAXbekqI0BTU3EBlSuObGio9wnKiuIm8Ggiprdjuw,17605
|
|
7
|
-
brukerapi/jcampdx.py,sha256=he6Y0cdeMzbsg7Ls0UX3iQ37677YikNkEjGAr27aPws,25218
|
|
8
|
-
brukerapi/mergers.py,sha256=IyNMesrhkdmexQgpO7vetaCJ-TSgN6zIatkLOv3mRMo,4067
|
|
9
|
-
brukerapi/schemas.py,sha256=o9c9PsxfZt0bYoeN4JXycSpAyRYOXocZXDTcnR9G-IY,25061
|
|
10
|
-
brukerapi/splitters.py,sha256=GZFvuDryBiWL7u2QrldWyd3-5btmATaYpMynWJOPIwM,15402
|
|
11
|
-
brukerapi/utils.py,sha256=kDKq1FV_E4mnROHALPEfv9aTfNy_QfIeZE6wB6IAn_E,1604
|
|
12
|
-
brukerapi/config/properties_2dseq_core.json,sha256=3JlQyDWhRiczFhLTXR0NS1OIxWwRljDBRvwlBtUnsfg,3919
|
|
13
|
-
brukerapi/config/properties_2dseq_custom.json,sha256=Kxic-Asg2am-vFtFHaHN_lxZdA8VEBUXlVeSPLbWLBw,9282
|
|
14
|
-
brukerapi/config/properties_fid_core.json,sha256=DYOKtJwqDhtKoJK1DPTuxofsiWwol2yXtnLfJp7TBzg,16076
|
|
15
|
-
brukerapi/config/properties_fid_custom.json,sha256=QIN3fryEbuV236D9GIOPmNkBYiKNXMByjTS4uubCmUM,1347
|
|
16
|
-
brukerapi/config/properties_rawdata_core.json,sha256=yksvjh5o4-t1e2VVzDSy_WuF5QzllovcwefxlIRJ188,2528
|
|
17
|
-
brukerapi/config/properties_rawdata_custom.json,sha256=RBNvo1WzZ4oRRq0W9-hknpT7T8If536DEMBg9hyq_4o,2
|
|
18
|
-
brukerapi/config/properties_traj_core.json,sha256=zx2gnPkVj9fUAL1iwixrtoRV7BlJpVTSYA4I-7s9Mzc,1956
|
|
19
|
-
brukerapi/config/properties_traj_custom.json,sha256=-KWibjBW62-wbe6z28z9iK50kAIAyYxwtZZru37J1N4,4
|
|
20
|
-
brukerapi-0.1.10.dist-info/licenses/LICENSE,sha256=qrKdH1kPjQsHQZxAS6dOSoPKyhrI0nKtNFVhG-fjDJw,1064
|
|
21
|
-
brukerapi-0.1.10.dist-info/METADATA,sha256=sIQDg55peXquqazXBn75rj2QXVJcanAZEX3jpFfMH0U,5317
|
|
22
|
-
brukerapi-0.1.10.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
23
|
-
brukerapi-0.1.10.dist-info/entry_points.txt,sha256=GkMTo84oMksVEhkrItYbnegKXFu0jyQHfOAvAn8z-Wo,46
|
|
24
|
-
brukerapi-0.1.10.dist-info/top_level.txt,sha256=32V6nLorM2P3LQY_gPPKEgDbeTF0N-HCAyUeEUsf2GU,10
|
|
25
|
-
brukerapi-0.1.10.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|