Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
zolfa-nd2reader
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lorenzo ZOLFANELLI
zolfa-nd2reader
Commits
62c86f34
Commit
62c86f34
authored
5 years ago
by
Gabriele Girelli
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update parser.py
parent
e5d4eebd
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
nd2reader/parser.py
+8
-6
8 additions, 6 deletions
nd2reader/parser.py
with
8 additions
and
6 deletions
nd2reader/parser.py
+
8
−
6
View file @
62c86f34
...
...
@@ -246,20 +246,22 @@ class Parser(object):
"""
return
{
channel
:
n
for
n
,
channel
in
enumerate
(
self
.
metadata
[
"
channels
"
])}
def
_remove_unwanted_bytes
(
self
,
image_group_data
,
image_data_start
,
height
,
width
):
# Remove unwanted 0-bytes that can appear in stitched images
number_of_true_channels
=
int
(
len
(
image_group_data
[
4
:])
/
(
height
*
width
))
unwanted_bytes
_len
=
(
len
(
image_group_data
[
image_data_start
:]))
%
(
height
*
width
)
if
not
unwanted_bytes
_len
:
n_
unwanted_bytes
=
(
len
(
image_group_data
[
image_data_start
:]))
%
(
height
*
width
)
if
not
n_
unwanted_bytes
:
return
warnings
.
warn
(
'
Identified unwanted bytes in the ND2 file, possibly stitched.
'
)
byte_ids
=
range
(
image_data_start
+
height
*
number_of_true_channels
,
len
(
image_group_data
)
-
unwanted_bytes_len
+
1
,
height
*
number_of_true_channels
)
assert
0
==
n_unwanted_bytes
%
height
,
"
Unexpected unwanted bytes distribution.
"
unwanted_byte_per_step
=
n_unwanted_bytes
//
height
byte_ids
=
range
(
image_data_start
+
height
*
number_of_true_channels
,
len
(
image_group_data
)
-
n_unwanted_bytes
+
1
,
height
*
number_of_true_channels
)
if
all
([
0
==
image_group_data
[
byte_ids
[
i
]
+
i
]
for
i
in
range
(
len
(
byte_ids
))]):
warnings
.
warn
(
'
All unwanted bytes are zero-bytes, correctly
removed.
'
)
warnings
.
warn
(
f
'
Identified
{
n_unwanted_bytes
}
(
{
unwanted_byte_per_step
}
*
{
height
}
) unwanted zero-bytes in the ND2 file,
removed.
'
)
for
i
in
range
(
len
(
byte_ids
)):
del
image_group_data
[
byte_ids
[
i
]]
else
:
warnings
.
warn
(
f
'
Identified
{
n_unwanted_bytes
}
unwanted non-zero bytes in the ND2 file.
'
)
def
_get_raw_image_data
(
self
,
image_group_number
,
channel_offset
,
height
,
width
):
"""
Reads the raw bytes and the timestamp of an image.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment