Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tomotools
tomoscan
Commits
a708f506
Commit
a708f506
authored
Oct 15, 2019
by
Pierre Paleo
Browse files
Replace single_frame with n_frames
parent
fdf72f92
Pipeline
#15709
passed with stages
in 3 minutes and 59 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
tomoscan/esrf/edfscan.py
View file @
a708f506
...
...
@@ -50,9 +50,10 @@ class EDFTomoScan(TomoScanBase):
:param scan: path to the root folder containing the scan.
:type: Union[str,None]
:param single_frame: Whether the EDF files contain one frame.
:param n_frames: Number of frames in each EDF file.
If not provided, it will be inferred by reading the files.
In this case, the frame number is guessed from the file name.
:type:
bool
:type:
Union[int, None]=None
"""
_TYPE
=
'edf'
...
...
@@ -66,7 +67,7 @@ class EDFTomoScan(TomoScanBase):
_SCHEME
=
'fabio'
def
__init__
(
self
,
scan
:
Union
[
str
,
None
],
single
_frame
:
bool
=
Fals
e
):
def
__init__
(
self
,
scan
:
Union
[
str
,
None
],
n
_frame
s
:
Union
[
int
,
None
]
=
Non
e
):
TomoScanBase
.
__init__
(
self
,
scan
=
scan
,
type_
=
self
.
_TYPE
)
# data caches
...
...
@@ -81,7 +82,7 @@ class EDFTomoScan(TomoScanBase):
self
.
__pixel_size
=
None
self
.
__ref_on
=
None
self
.
__scan_range
=
None
self
.
_edf_
single
_frame
=
single
_frame
self
.
_edf_
n
_frame
s
=
n
_frame
s
self
.
update
()
@
docstring
(
TomoScanBase
.
tomo_n
)
...
...
@@ -216,7 +217,7 @@ class EDFTomoScan(TomoScanBase):
@
docstring
(
TomoScanBase
.
update
)
def
update
(
self
):
self
.
projections
=
EDFTomoScan
.
get_proj_urls
(
self
.
path
,
single
_frame
=
self
.
_edf_
single
_frame
)
self
.
projections
=
EDFTomoScan
.
get_proj_urls
(
self
.
path
,
n
_frame
s
=
self
.
_edf_
n
_frame
s
)
self
.
_darks
=
EDFTomoScan
.
get_darks_url
(
self
.
path
)
self
.
_flats
=
EDFTomoScan
.
get_refs_url
(
self
.
path
)
...
...
@@ -234,7 +235,7 @@ class EDFTomoScan(TomoScanBase):
return
self
@
staticmethod
def
get_proj_urls
(
scan
:
str
,
single
_frame
:
bool
=
Fals
e
)
->
dict
:
def
get_proj_urls
(
scan
:
str
,
n
_frame
s
:
Union
[
int
,
None
]
=
Non
e
)
->
dict
:
"""
Return the dict of radios / projection for the given scan.
Keys of the dictionary is the slice number
...
...
@@ -243,9 +244,9 @@ class EDFTomoScan(TomoScanBase):
:param scan: is the path to the folder of acquisition
:type: str
:param single_frame:
Whether the EDF are single frames. In this case,
The projection number is guessed from the file nam
e.
:type:
bool
:param single_frame:
Number of frames in each EDF file.
If not provided, it is inferred by reading each fil
e.
:type:
int
:return: dict of radios files with radio index as key and file as value
:rtype: dict
"""
...
...
@@ -260,7 +261,7 @@ class EDFTomoScan(TomoScanBase):
index
=
EDFTomoScan
.
guess_index_frm_file_name
(
gfile
)
urls
.
update
(
extract_urls_from_edf
(
start_index
=
index
,
file_
=
gfile
,
single_frame
=
single
_frame
))
n_frames
=
n
_frame
s
))
return
urls
...
...
tomoscan/esrf/utils.py
View file @
a708f506
...
...
@@ -66,22 +66,22 @@ def get_parameters_frm_par_or_info(file_: str) -> dict:
return
ddict
def
extract_urls_from_edf
(
file_
:
str
,
start_index
:
Union
[
None
,
int
],
single
_frame
:
bool
=
Fals
e
)
->
dict
:
def
extract_urls_from_edf
(
file_
:
str
,
start_index
:
Union
[
None
,
int
],
n
_frame
s
:
Union
[
int
,
None
]
=
Non
e
)
->
dict
:
"""return one DataUrl for each frame contain in the file_
:param file_: path to the file to parse
:type:str
:param n_frames: Number of frames in each edf file (inferred if not told)
:type: Union[int, None]
:param start_index:
:type: Union[None,start_index]
"""
res
=
{}
index
=
0
if
start_index
is
None
else
start_index
if
single_frame
:
nframes
=
1
else
:
if
n_frames
is
None
:
with
fabio
.
open
(
file_
)
as
fabio_file
:
nframes
=
fabio_file
.
nframes
for
i_frame
in
range
(
nframes
):
n
_
frames
=
fabio_file
.
nframes
for
i_frame
in
range
(
n
_
frames
):
res
[
index
]
=
DataUrl
(
scheme
=
'fabio'
,
file_path
=
file_
,
data_slice
=
[
i_frame
,
])
index
+=
1
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment