Skip to content
Snippets Groups Projects
Commit 85d2a86d authored by Constantin Pape's avatar Constantin Pape
Browse files

Add functionality to autogenerate additional table file and add it to 0.6.3

parent fee6be44
No related branches found
No related tags found
No related merge requests found
profile_clust_curated.csv
cells_to_nuclei.csv
extrapolated_intensity_correction.csv
genes.csv
morphology.csv
regions.csv
vc_assignments.csv
cell_mapping.csv
morphology.csv
extrapolated_intensity_correction.csv
morphology.csv
......@@ -160,6 +160,34 @@ def base_attributes(input_path, input_key, output_path, resolution,
return label_ids
def write_additional_table_file(table_folder):
# get all the file names in the table folder
file_names = os.listdir(table_folder)
file_names.sort()
# make sure we have the default table
default_name = 'default.csv'
if default_name not in file_names:
raise RuntimeError("Did not find the default table ('default.csv') in the table folder %s" % table_folder)
# don't write anything if we don't have additional tables
if len(file_names) == 1:
return
# write file for the additional tables
out_file = os.path.join(table_folder, 'additional_tables.txt')
with open(out_file, 'w') as f:
for name in file_names:
ext = os.path.splitext(name)[1]
# only add csv files
if ext != '.csv':
continue
# don't add the default table
if name == 'default.csv':
continue
f.write(name + '\n')
# TODO this is un-tested !!!
def propagate_attributes(id_mapping_path, old_table_path, output_path):
""" Propagate all attributes to new ids. (column label id)
......
import os
import h5py
from .base_attributes import base_attributes, propagate_attributes
from .base_attributes import base_attributes, propagate_attributes, write_additional_table_file
from .cell_nucleus_mapping import map_cells_to_nuclei
from .genes import gene_assignment_table, vc_assignment_table
from .morphology import write_morphology_cells, write_morphology_nuclei
......@@ -84,6 +84,8 @@ def make_cell_tables(old_folder, folder, name, tmp_folder, resolution,
extrapol_mask, 't00000/s00/0/cells',
extrapol_out, tmp_folder, target, max_jobs)
write_additional_table_file(table_folder)
def make_nucleus_tables(old_folder, folder, name, tmp_folder, resolution,
target='slurm', max_jobs=100):
......@@ -117,6 +119,8 @@ def make_nucleus_tables(old_folder, folder, name, tmp_folder, resolution,
extrapol_mask, 't00000/s00/0/cells',
extrapol_out, tmp_folder, target, max_jobs)
write_additional_table_file(table_folder)
def make_cilia_tables(old_folder, folder, name, tmp_folder, resolution,
target='slurm', max_jobs=100):
......@@ -144,3 +148,5 @@ def make_cilia_tables(old_folder, folder, name, tmp_folder, resolution,
cilia_morphology(seg_path, seg_key,
base_out, morpho_out, resolution,
tmp_folder, target=target, max_jobs=max_jobs)
write_additional_table_file(table_folder)
......@@ -2,6 +2,7 @@ import os
import shutil
from .xml_utils import copy_xml_with_newpath, get_h5_path_from_xml
from .sources import get_image_names, get_segmentation_names, get_segmentations
from ..attributes.base_attributes import write_additional_table_file
def copy_file(xml_in, xml_out):
......@@ -28,6 +29,8 @@ def copy_tables(src_folder, dst_folder, name):
rel_path = os.path.relpath(src_file, table_out)
if not os.path.exists(dst_file):
os.symlink(rel_path, dst_file)
# write the txt file for additional tables
write_additional_table_file(dst_folder)
def copy_segmentation(src_folder, dst_folder, name):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment