Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SVLT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ALMF
SVLT
Commits
be78a9d9
Commit
be78a9d9
authored
1 year ago
by
Christopher Randolph Rhodes
Browse files
Options
Downloads
Patches
Plain Diff
Add EcoTaxa-spec'd TSV export to batch running script
parent
d962a3de
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
extensions/chaeo/actual_runs/20231008_Bilbao_PA.py
+40
-14
40 additions, 14 deletions
extensions/chaeo/actual_runs/20231008_Bilbao_PA.py
with
40 additions
and
14 deletions
extensions/chaeo/actual_runs/20231008_Bilbao_PA.py
+
40
−
14
View file @
be78a9d9
from
pathlib
import
Path
import
pandas
as
pd
from
extensions.chaeo.util
import
autonumber_new_directory
,
get_matching_files
,
loop_workflow
from
extensions.chaeo.workflows
import
export_patches_from_multichannel_zstack
from
model_server.accessors
import
CziImageFileAccessor
,
write_accessor_data_to_file
,
InMemoryDataAccessor
from
model_server.process
import
rescale
def
write_ecotaxa_tsv
(
patches_csv_path
,
where
):
# import patch output table
df_patches
=
pd
.
read_csv
(
patches_csv_path
)
df_patches
[
'
img_file_name
'
]
=
df_patches
[
'
patch_filename
'
].
apply
(
lambda
x
:
'
2d_patches_annotation/
'
+
x
)
def
export_single_channel_tif_from_multichannel_czi
(
input_file_path
,
output_folder_path
,
channel
,
**
kwargs
):
in_acc
=
CziImageFileAccessor
(
input_file_path
)
data
=
in_acc
.
get_one_channel_data
(
channel
).
data
if
'
rescale_zmask_clip
'
in
kwargs
:
data
=
rescale
(
data
,
clip
=
kwargs
[
'
rescale_zmask_clip
'
])
outf
=
Path
(
output_folder_path
)
/
(
Path
(
input_file_path
).
stem
+
'
.tif
'
)
write_accessor_data_to_file
(
outf
,
InMemoryDataAccessor
(
data
),
# make second column index level to comply w/ EcoTaxa schema
df_patches
.
columns
=
pd
.
MultiIndex
.
from_frame
(
pd
.
DataFrame
([
df_patches
.
columns
,
df_patches
.
dtypes
.
apply
(
lambda
x
:
'
[f]
'
if
x
in
[
'
float64
'
]
else
'
[t]
'
)
]).
T
,
names
=
[
'
variable
'
,
'
data type
'
]
)
print
(
f
'
Wrote file:
{
outf
}
'
)
# add new columns for ecotaxa
df_patches
.
loc
[:,
(
'
acq_instrument
'
,
'
[t]
'
)]
=
'
Other microscope
'
df_patches
.
loc
[:,
(
'
acq_instrument_microscope
'
,
'
[t]
'
)]
=
'
EMBL-MS-Zeiss-LSM900
'
df_patches
.
loc
[:,
(
'
sample_id
'
,
'
[t]
'
)]
=
'
20231008-bilbao
'
df_patches
.
loc
[:,
(
'
acq_id
'
,
'
[t]
'
)]
=
df_patches
.
loc
[:,
(
'
input_file
'
,
'
[t]
'
)]
df_patches
.
loc
[:,
(
'
object_id
'
,
'
[t]
'
)]
=
df_patches
.
loc
[:,
(
'
patch_id
'
,
'
[t]
'
)]
df_patches
.
loc
[:,
(
'
process_id
'
,
'
[t]
'
)]
=
df_patches
.
loc
[:,
(
'
patch_id
'
,
'
[t]
'
)]
cols_to_transfer
=
[
'
img_file_name
'
,
'
object_id
'
,
'
acq_id
'
,
'
acq_instrument
'
,
'
acq_instrument_microscope
'
,
'
sample_id
'
,
'
process_id
'
]
df_export
=
df_patches
.
loc
[:,
pd
.
IndexSlice
[
cols_to_transfer
,
:]]
df_export
.
to_csv
(
Path
(
where
)
/
'
ecotaxa.tsv
'
,
sep
=
'
\t
'
,
index
=
False
)
if
__name__
==
'
__main__
'
:
root
=
Path
(
'
c:/Users/rhodes/projects/proj0012-trec-handoff/owncloud-sync/TREC-HD/Images/
'
)
...
...
@@ -48,7 +71,7 @@ if __name__ == '__main__':
'
export_patch_masks
'
:
True
,
'
rescale_zmask_clip
'
:
0.01
,
'
rgb_overlay_channels
'
:
(
1
,
None
,
None
),
'
rgb_overlay_weights
'
:
(
0.
5
,
1.0
,
1.0
)
'
rgb_overlay_weights
'
:
(
0.
2
,
1.0
,
1.0
)
}
input_files
=
get_matching_files
(
where_czi
,
'
czi
'
,
coord_filter
=
{})
...
...
@@ -61,4 +84,7 @@ if __name__ == '__main__':
catch_and_continue
=
False
,
)
csv_path
=
(
Path
(
where_output
)
/
'
workflow_data.csv
'
).
__str__
()
write_ecotaxa_tsv
(
csv_path
,
where_output
)
print
(
'
Finished
'
)
\ No newline at end of file
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