Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
Brain volume analysis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
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
Monitor
Incidents
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
imcf
Brain volume analysis
Commits
ece8f048
Commit
ece8f048
authored
2 years ago
by
Kai Schleicher
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parent
6cf9e29c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
remap_labelimage.py
+29
-0
29 additions, 0 deletions
remap_labelimage.py
with
29 additions
and
0 deletions
remap_labelimage.py
0 → 100644
+
29
−
0
View file @
ece8f048
#@ File inputfile
from
ij
import
IJ
from
inra.ijpb.label
import
LabelImages
from
ij.measure
import
ResultsTable
import
os.path
path
,
ext
=
os
.
path
.
splitext
(
str
(
inputfile
))
parent_dir
,
filename
=
os
.
path
.
split
(
path
)
label_imp
=
IJ
.
openImage
(
str
(
inputfile
))
IJ
.
log
(
"
remapping labels...
"
)
original_labels
=
LabelImages
.
findAllLabels
(
label_imp
)
LabelImages
.
remapLabels
(
label_imp
)
remapped_labels
=
LabelImages
.
findAllLabels
(
label_imp
)
atlas_map
=
ResultsTable
()
for
index
,
value
in
enumerate
(
sorted
(
original_labels
)):
atlas_map
.
setValue
(
"
original labels
"
,
index
,
value
)
for
index
,
value
in
enumerate
(
sorted
(
remapped_labels
)):
atlas_map
.
setValue
(
"
remapped labels
"
,
index
,
value
)
IJ
.
log
(
"
saving results...
"
)
IJ
.
run
(
"
Input/Output...
"
,
"
file=.csv save_column save_row
"
)
atlas_map
.
save
(
parent_dir
+
"
/
"
+
filename
+
"
_labelmap.csv
"
)
IJ
.
saveAs
(
label_imp
,
"
Tiff
"
,
parent_dir
+
"
/
"
+
filename
+
"
_remapped.tif
"
)
label_imp
.
close
()
IJ
.
log
(
"
done
"
)
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