Skip to content

Gina push req #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 262 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
262 commits
Select commit Hold shift + click to select a range
6034604
Config file for permutation stats as cli arguments were getting too l…
nrhorner Apr 1, 2021
3dd625a
files for snake contour contour (to fix poor registrations) - needs d…
dorkylever Apr 13, 2021
955ab4b
update for two_way stats
dorkylever Apr 13, 2021
7d221b0
Add two_way stats
dorkylever Apr 13, 2021
c7af713
update for two_way_stats
dorkylever Apr 13, 2021
2a995fe
update for two_way stats
dorkylever Apr 13, 2021
160755c
update for two_way stats
dorkylever Apr 13, 2021
e82bc1b
update for two_way stats
dorkylever Apr 13, 2021
3214350
udpate lmFast to do two-way ANOVA if genotype and treatment are present
dorkylever Apr 13, 2021
fc5f8a5
Update data_loaders.py
dorkylever Apr 13, 2021
0bd253a
Update lama_stats.py
dorkylever Apr 14, 2021
6ed5020
only do interaction specimen to reduce multiple testing
dorkylever Apr 14, 2021
ec0d638
Update stats_objects.py
dorkylever Apr 20, 2021
2b9a210
Update lmFast.R
dorkylever Apr 20, 2021
3452871
changed stats from ANOVA to just a lm
dorkylever Apr 23, 2021
4e57ebb
Heatmap typo fixed
nrhorner Apr 25, 2021
2926642
Fixed permutation stats bugs when using QC file
nrhorner Apr 25, 2021
8755c12
Moved organ vol permutation stats to statsmodels
nrhorner Apr 27, 2021
59fdbaa
Fixed bug when heatmaps die due to no results for that line
nrhorner Apr 27, 2021
358b816
Fixed some plottong issues
nrhorner Apr 29, 2021
aa86d4a
Change default depth back to 5 in paths.walk
nrhorner Apr 29, 2021
26a8647
Permutation stats now produces summary of line and speciemn hits csv
nrhorner Apr 29, 2021
9f7f116
Script arg problem fixed
nrhorner May 4, 2021
ebe1eec
Merge branch 'mpi2:master' into master
dorkylever May 11, 2021
84bed40
Bins the jacobians/voxels into blocks for perm stats
dorkylever May 11, 2021
b049b93
Bug in data loader
nrhorner Jun 3, 2021
eda1096
Merge branch 'mpi2:master' into master
dorkylever Jun 8, 2021
e5114a8
Fixed bug that affected FDR reported when there were no FDRs below ta…
nrhorner Jun 15, 2021
fcd4442
Fixed NA issue with p-value distribution plots
nrhorner Jun 15, 2021
a4b630f
Fix the warning when not enough smaples for permutations
nrhorner Jun 15, 2021
a9800dc
version update
nrhorner Jun 15, 2021
70e5af7
Updates to permutation method3
nrhorner Jun 16, 2021
ea03248
Version update
nrhorner Jun 17, 2021
9987820
Added git commit logging for non-PyPi installs (Which include a curre…
nrhorner Jun 17, 2021
fc63651
Organ vol plots paths bug
nrhorner Jun 21, 2021
ed17e64
Fixed git log issue
nrhorner Jun 21, 2021
62a6980
still run LAMA if git commit cannot be determined
dorkylever Jun 22, 2021
0337cb2
Merge pull request #38 from Dorky-Lever/patch-3
nrhorner Jun 23, 2021
c4e007a
merged Kyle's chnages
nrhorner Jun 23, 2021
1562b66
Added gitpython to setup.py
nrhorner Jun 23, 2021
518691c
Added exception for where no git exists on the system
nrhorner Jun 23, 2021
6b9c741
Merge branch 'mpi2:master' into master
dorkylever Jun 24, 2021
10ea509
Made default output directory for permutation stats to be config pare…
nrhorner Jun 24, 2021
15b22c7
Fixed permutation stats bug with emty entries in label metadataa 'sho…
nrhorner Jun 24, 2021
21e9391
Added config key check for permutation stats
nrhorner Jun 24, 2021
b1774aa
Version upgrade
nrhorner Jun 24, 2021
2454432
Updating to higher version. Went backwars last commit by accident
nrhorner Jun 24, 2021
1db7be6
Create make_roi.py
dorkylever Jul 2, 2021
2aa7bd9
?
nrhorner Jul 15, 2021
8a93d49
Merge branch 'mpi2:master' into master
dorkylever Jul 23, 2021
e822811
Can I steal dev for pytorch-3dunet stuff
dorkylever Jul 25, 2021
a28871b
Just random scripts that I've made along the way
dorkylever Jul 27, 2021
5323b7d
Just for binning intensity / jacobian data
dorkylever Jul 27, 2021
5f01573
Update stats_objects.py
dorkylever Jul 27, 2021
86b3e37
Updated config option
nrhorner Jul 28, 2021
f18f131
Added missing imported file atlas_tools.py
nrhorner Jul 28, 2021
adf21b3
Merge branch 'mpi2:master' into master
dorkylever Jul 29, 2021
9ae7ade
Add files via upload
dorkylever Jul 29, 2021
1942aa7
configs for test_two_way_stats
dorkylever Jul 29, 2021
0376cd0
Adding git logging to perm stats. Couple of test changes
nrhorner Jul 29, 2021
4c840ee
Update stats_objects.py
dorkylever Jul 30, 2021
655fbad
Update results_writer.py
dorkylever Jul 30, 2021
2273626
Update results_writer.py
dorkylever Jul 30, 2021
366f7fa
Update data_loaders.py
dorkylever Jul 30, 2021
92e4c30
Update lama_stats_new.py
dorkylever Jul 30, 2021
8789e60
Update stats_objects.py
dorkylever Jul 30, 2021
42ab896
Update lama_stats_new.py
dorkylever Jul 30, 2021
1bd9577
Update stats_objects.py
dorkylever Jul 30, 2021
4394178
Fixed bug in permutaitn stats where noralisation occured multiple times
nrhorner Jul 30, 2021
47f61b3
reduce the number of if statements
dorkylever Aug 2, 2021
3ccfed0
added flag for two-way loading vs writing
dorkylever Aug 2, 2021
61dc314
Create nrrd_to_h5.py
dorkylever Aug 3, 2021
df9a7d0
combines multiple .csv files within the registration directory into o…
dorkylever Aug 10, 2021
eee64b5
converted integer spec_id to strings
henrik-impc Sep 15, 2021
7a5256a
Pad np.min of the volumes instead of 0
dorkylever Oct 14, 2021
daa0f43
Update lama_stats_new.py
dorkylever Oct 14, 2021
62de1db
Update lama_stats_new.py
dorkylever Oct 14, 2021
5518f27
Merge branch 'master' of https://github.com/mpi2/LAMA into mpi2-master
Oct 15, 2021
f386f88
Update lama_stats_new.py
dorkylever Oct 23, 2021
8ca9e4e
make plots is happening to early so commented out of run_permutation_…
henrik-impc Nov 17, 2021
2cde8b2
Update cropper.py
dorkylever Nov 22, 2021
cc187fc
Add files via upload
dorkylever Nov 22, 2021
8c1785c
Add files via upload
dorkylever Nov 22, 2021
6a4eca8
Merge branch 'mpi2:master' into master
dorkylever Nov 23, 2021
5ce0962
Update stats_objects.py
dorkylever Dec 1, 2021
82ffa5c
removed np.shape from one-way stats
dorkylever Dec 1, 2021
61d20b4
test
dorkylever Feb 1, 2022
ffc2bfd
test
dorkylever Feb 8, 2022
7072412
test
dorkylever Feb 9, 2022
1a6cebc
test
dorkylever Feb 9, 2022
c9e2d13
default writing for Ben
dorkylever Feb 10, 2022
a53f252
Little Things
dorkylever Feb 11, 2022
b4b43f6
Little Things
dorkylever Feb 13, 2022
e04fc0f
Line Annotations for two way studies are built
dorkylever Feb 14, 2022
7d0c1cf
Line Annotations for two way studies are built
dorkylever Feb 14, 2022
7470def
bug fixes
dorkylever Feb 15, 2022
2b2b640
Alpha Version of permuation two-way statistics
dorkylever Feb 16, 2022
2dfc85b
Alpha Version of radiomics normaliser for Ben Quah
dorkylever Feb 22, 2022
36f4889
updating dependency test
dorkylever Feb 28, 2022
6027796
updating dependency test
dorkylever Feb 28, 2022
82ca9ed
updating dependency test
dorkylever Mar 6, 2022
c067137
Update setup.py
dorkylever Mar 7, 2022
2fff8c2
Update radiomics_normaliser.py
dorkylever Mar 7, 2022
dbd0fff
radiomics normaliser on NCI
dorkylever Mar 7, 2022
572c5f6
update intensity normalisation methods for two_ways
dorkylever Mar 9, 2022
1bb13e0
update intensity normalisation methods for two_ways
dorkylever Mar 9, 2022
f8b3a86
update intensity normalisation methods for two_ways
dorkylever Mar 9, 2022
b2a3497
update intensity normalisation methods for two_ways
dorkylever Mar 10, 2022
5cd310b
update intensity normalisation methods for one_way
dorkylever Mar 10, 2022
d85519f
testing_radiomics_normaliser
dorkylever Mar 12, 2022
4dbec98
testing_radiomics_normaliser
dorkylever Mar 12, 2022
4c44db0
testing_radiomics_normaliser
dorkylever Mar 13, 2022
1e1541f
testing_radiomics_normaliser
dorkylever Mar 14, 2022
ef2b45d
testing_radiomics_normaliser
dorkylever Mar 14, 2022
2e4599c
testing_radiomics_normaliser
dorkylever Mar 17, 2022
054fdf5
command line for arkell image processing
dorkylever Mar 18, 2022
2e047f2
command line for arkell image processing
dorkylever Mar 21, 2022
63dc586
command line for arkell image processing
dorkylever Mar 21, 2022
1e9ae25
command line for arkell image processing
dorkylever Mar 21, 2022
d5709f2
command line for arkell image processing
dorkylever Mar 22, 2022
252d20b
command line for arkell image processing
dorkylever Mar 23, 2022
3e61aa3
command line for arkell image processing
dorkylever Mar 23, 2022
e5fc2fe
command line for arkell image processing
dorkylever Mar 23, 2022
8f24528
command line for arkell image processing
dorkylever Mar 31, 2022
cf31c43
command line for arkell image processing
dorkylever Mar 31, 2022
b75095e
command line for arkell image processing
dorkylever Mar 31, 2022
440e28a
command line for arkell image processing
dorkylever Mar 31, 2022
d2daa1d
command line for arkell image processing
dorkylever Mar 31, 2022
5fe0be3
command line for arkell image processing
dorkylever Apr 3, 2022
e3aa39c
command line for arkell image processing
dorkylever Apr 4, 2022
0c12229
two_way_permutation_plotting
dorkylever Apr 29, 2022
1811264
Apply fixes to two_way_plotter.py
dorkylever May 10, 2022
a0d1fc0
Apply fixes to two_way_plotter.py
dorkylever May 10, 2022
7bc9cb6
fixing two_way_plotter.py
dorkylever May 10, 2022
abf091a
Further progress two-way perm stats
dorkylever May 13, 2022
5b1a2d7
ptwo way perm testing
dorkylever May 20, 2022
8fa8611
fix error in skip no analysis
dorkylever May 20, 2022
823b208
rough working two-way perm
dorkylever May 21, 2022
5720645
Get histogram matching to use the pop avg as the target
dorkylever May 24, 2022
f9de413
start of making radiomics stats pipeline
dorkylever Jun 9, 2022
7156882
start of making radiomics stats pipeline
dorkylever Jun 17, 2022
0717ace
start of making radiomics stats pipeline
dorkylever Jun 19, 2022
4df919a
start of making radiomics stats pipeline
dorkylever Jun 19, 2022
d5ea82b
Establishing NCI pip
dorkylever Jun 19, 2022
90ebd86
Establishing NCI pip
dorkylever Jun 19, 2022
d30a0ba
implement N4 intensity correction
dorkylever Jun 19, 2022
76e35ae
start of parallelising radiomics.py
dorkylever Jun 19, 2022
80cd586
start of parallelising radiomics.py
dorkylever Jun 20, 2022
18e2330
start of parallelising radiomics.py
dorkylever Jun 20, 2022
bf18f8f
radiomics.py seems functional
dorkylever Jun 23, 2022
f3efc32
job_runner and radiomics now checks for hung jobs
dorkylever Jul 10, 2022
b13ae43
job_runner and radiomics now checks for hung jobs
dorkylever Jul 10, 2022
319ae2a
job_runner and radiomics now checks for hung jobs
dorkylever Jul 10, 2022
9be2902
job_runner and radiomics now checks for hung jobs
dorkylever Jul 10, 2022
639e5c3
job_runner and radiomics now checks for hung jobs
dorkylever Jul 13, 2022
b89dd3a
Pyyaml is super high?
dorkylever Jul 13, 2022
6190e06
Pyyaml is super high?
dorkylever Jul 15, 2022
33e205f
Normalisation methods should work for both BQ and KD data
dorkylever Jul 15, 2022
0638927
command_line_for_plotter (NOTE plotting doesn't work - use to extract…
dorkylever Jul 18, 2022
bfd17d7
command_line_for_plotter (NOTE plotting doesn't work - use to extract…
dorkylever Jul 18, 2022
a243a2c
command_line_for_plotter (NOTE plotting doesn't work - use to extract…
dorkylever Jul 18, 2022
556f9cd
command_line_for_plotter (NOTE plotting doesn't work - use to extract…
dorkylever Jul 19, 2022
9973f93
radiomics again
dorkylever Jul 19, 2022
36479fd
Mask intensity normalisation is now functional
dorkylever Jul 20, 2022
5003e80
Mask intensity normalisation is now functional
dorkylever Jul 20, 2022
d438d02
radiomics again
dorkylever Jul 22, 2022
bafaeb8
removed print statemets
dorkylever Jul 24, 2022
df3227f
fixed bug in perm code
dorkylever Jul 26, 2022
5af8d4a
testing pacmap install
dorkylever Aug 1, 2022
fd564bc
Add files via upload
dorkylever Aug 5, 2022
f15f093
Mask intensity normalisation is now functional
dorkylever Aug 7, 2022
249e9eb
Mask intensity normalisation is now functional
dorkylever Aug 7, 2022
8fdc22e
testing_feature_selection for BQ
dorkylever Aug 7, 2022
dcf242e
testing_feature_selection for BQ
dorkylever Aug 8, 2022
da634af
fixed bug in two_way_perm for main effects
dorkylever Aug 9, 2022
c64831a
heatmaps are made for main effects in two_way permutation stats
dorkylever Aug 10, 2022
1333705
fix two-way perm and rad feat reduction
dorkylever Aug 14, 2022
bfe8c54
draft ml pipeline
dorkylever Aug 15, 2022
7bde4cf
draft ml pipeline
dorkylever Aug 30, 2022
a23f590
draft ml pipeline
dorkylever Sep 1, 2022
28a6249
draft ml pipeline
dorkylever Sep 1, 2022
47687a5
draft ml pipeline parallelisation
dorkylever Sep 2, 2022
9934438
draft ml pipeline parallelisation
dorkylever Sep 2, 2022
e505b8b
draft ml pipeline parallelisation
dorkylever Sep 2, 2022
4f4b658
draft ml pipeline parallelisation
dorkylever Sep 4, 2022
5489112
draft ml pipeline parallelisation
dorkylever Sep 5, 2022
6466983
job-locked machine_learning.py
dorkylever Sep 8, 2022
9ecaedc
job-locked machine_learning.py
dorkylever Sep 8, 2022
407b953
job-locked machine_learning.py
dorkylever Sep 9, 2022
d6bf2d9
fix Bq radiomics
dorkylever Sep 11, 2022
21ddf70
job-locked machine_learning.py
dorkylever Sep 12, 2022
c60042e
job-locked machine_learning.py
dorkylever Sep 12, 2022
48d575e
hung jobs patched
dorkylever Sep 13, 2022
4bce6d0
hung jobs patched
dorkylever Sep 17, 2022
6774cc7
dependency control
dorkylever Sep 29, 2022
24494e1
dependency control
dorkylever Sep 29, 2022
05c9adc
dependency control
dorkylever Sep 29, 2022
03cb894
Add files via upload
dorkylever Oct 26, 2022
028aa29
fix Bq radiomics
dorkylever Oct 27, 2022
d00e93e
test catboost on NCI
dorkylever Nov 21, 2022
f673f65
Merge remote-tracking branch 'origin/dev2' into dev2
dorkylever Nov 21, 2022
5bb1b0c
test catboost on NCI
dorkylever Nov 21, 2022
48ad299
test catboost on NCI
dorkylever Nov 21, 2022
8ac5343
test catboost on NCI
dorkylever Nov 21, 2022
bf11e8e
catboost
dorkylever Nov 25, 2022
f88607d
perm_stats yaml fix
dorkylever Nov 26, 2022
6cba411
perm_stats yaml fix
dorkylever Nov 26, 2022
7446a1e
fixing invert stara
dorkylever Nov 28, 2022
9eccf29
add make job file argument for easier parallelisation
dorkylever Nov 29, 2022
7e90017
Merge remote-tracking branch 'origin/dev2' into dev2
dorkylever Nov 29, 2022
2615aad
add make job file argument for easier parallelisation
dorkylever Nov 29, 2022
81b69b2
machine_learning is a now a script
dorkylever Nov 29, 2022
bc58542
added make_org_files to make org files from radiomic features output
dorkylever Nov 30, 2022
cfadcba
machine_learning is a now a script
dorkylever Dec 1, 2022
74bee30
trialling model stacking
dorkylever Dec 1, 2022
edc1d8f
added undersampling if required
dorkylever Dec 1, 2022
f345360
added undersampling if required
dorkylever Dec 1, 2022
4db327b
invert heatmaps should work for two-way stats now!!
dorkylever Dec 5, 2022
a326425
removed hard coding from permutation stats
dorkylever Dec 7, 2022
f60c738
fix rad error for BQ
dorkylever Dec 18, 2022
3f0a739
fix rad error for BQ
dorkylever Dec 18, 2022
a25b090
fix rad error for BQ
dorkylever Dec 18, 2022
aca603a
calculate shap via catboost.get_feature_importance for major speed im…
dorkylever Dec 19, 2022
443e602
calculate shap via catboost.get_feature_importance for major speed im…
dorkylever Feb 3, 2023
e96d432
removed unneccessary looping in SHAP reduction / cv validaton due to …
dorkylever Feb 5, 2023
ebb2d77
bug_fix
dorkylever Feb 10, 2023
eb9fce1
bug_fix
dorkylever Feb 13, 2023
3ef47b9
start_of_rad_perm
dorkylever Feb 15, 2023
03fb629
start_of_rad_perm
dorkylever Feb 15, 2023
5c13cf4
fix scikit learn
dorkylever Feb 16, 2023
4525c72
fix scikit learn
dorkylever Feb 16, 2023
b63c025
removed Neil's hard label coding
dorkylever Feb 18, 2023
4bf0950
attempt to fix radiomics parallelisation
dorkylever Feb 18, 2023
bfa4c08
attempt to fix radiomics parallelisation
dorkylever Feb 20, 2023
dd11265
attempt to fix radiomics parallelisation
dorkylever Feb 22, 2023
93043b2
attempt to fix radiomics parallelisation
dorkylever Mar 7, 2023
938d44a
attempt to fix radiomics parallelisation
dorkylever Mar 7, 2023
cc58c70
potential speed improvements in radiomics feature extraction
dorkylever Mar 7, 2023
44f9535
The speed improvements did not work, refix
dorkylever Mar 15, 2023
5527d64
The speed improvements did not work, refix
dorkylever Mar 15, 2023
90782b2
mergning BQ code to create a standalone
dorkylever Mar 20, 2023
8b82b44
controlling the specimen FDR may be handy later
dorkylever Mar 20, 2023
7ece1d7
controlling the specimen FDR may be handy later
dorkylever Mar 21, 2023
fd348de
perm stats should work for rad and ovs
dorkylever Mar 22, 2023
3395dd3
perm stats should work for rad and ovs
dorkylever Mar 23, 2023
fa2c370
fixed python 3.7 issue
dorkylever Mar 24, 2023
97ff61e
fixed python 3.7 issue
dorkylever Mar 24, 2023
92fb95d
update for BQ
dorkylever Mar 30, 2023
da3c50c
test
dorkylever Apr 3, 2023
6bf4f94
test brancg
dorkylever Apr 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions CHANGELOG.md

This file was deleted.

1 change: 1 addition & 0 deletions __init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from lama.version import __version__
1 change: 1 addition & 0 deletions lama/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
# When running from a docker image, get much warnings from sklearn, pandas etc. Turn it off
warnings.filterwarnings("ignore")

from .version import __version__

#matplotlib.use('Agg')
74 changes: 67 additions & 7 deletions lama/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
import pandas as pd
import psutil
import argparse
try:
import git
except ImportError:
git = None

import yaml
import toml
Expand Down Expand Up @@ -264,6 +268,18 @@ def read_array( path: Union[str, Path]):
return sitk.GetArrayFromImage(sitk.ReadImage(path))


def read_spec_csv(path: Union[Path, str]) -> pd.DataFrame:
"""
Read a CSV containing specimen data (such as organ or whole mask volumes.
Force index to be str type

TODO: Should we enforce column header to be str as well?
"""
df = pd.read_csv(path, index_col=0)
df.index = df.index.astype(str)
return df


def img_path_to_array(img_path: Union[str, Path]):
if os.path.isfile(img_path):
try:
Expand All @@ -288,14 +304,29 @@ def git_log() -> str:
the git branch, commit, and message
"""
this_dir = Path(__file__).parent.resolve()
git_msg_file = this_dir / 'current_commit'
git_msg_file = this_dir / 'current_commit1'

try:
msg = ''
with open(git_msg_file, 'r') as fh:
for line in fh:
msg += line
except OSError:
# current_commit file does not exist (This would come from pip install).
# So try using git
if git:
try:
this_module = Path(__file__).parent
repo = git.Repo(search_parent_directories=True, path=this_module)
sha = repo.head.object.hexsha[:7]
msg = f'Git commit: {sha}'
# Kyle -if the git commit can not be determined, for example
# running python3 setup.py install --user installs into site packages
# stuffing the git commit up - you get the error below and stops LAMA
# from running - hence the extra try except
except git.exc.InvalidGitRepositoryError:
pass
if not msg:
msg = f'Cannot determine git commit'

return msg
Expand Down Expand Up @@ -363,7 +394,7 @@ def load_label_map_names(organ_names_path, include_terms=False):
df = pd.read_csv(organ_names_path)

# Drop clear label, if present
if df.iloc[0].label == 0:
if df.iloc[0].label_num == 0:
df.drop(0, inplace=True)

# Check required columns are present
Expand Down Expand Up @@ -779,6 +810,31 @@ def csv_read_dict(path):
return lines


def gather_rad_data(_dir):
file_names = [spec for spec in get_file_paths(folder=_dir, extension_tuple=".csv")]
file_names.sort()
data = [pd.read_csv(spec, index_col=0).dropna(axis=1) for spec in file_names]
abnormal_embs = ['22300_e8', '22300_e6', '50_e5']
for i, df in enumerate(data):
df.index.name = 'org'
df.name = str(file_names[i]).split(".")[0].split("/")[-1]
df['genotype'] = 'HET' if 'het' in str(file_names[i]) else 'WT'
df['background'] = 'C57BL6N' if (('b6ku' in str(file_names[i])) | ('BL6' in str(file_names[i]))) else \
'F1' if ('F1' in str(file_names[i])) else 'C3HHEH'
df['HPE'] = 'abnormal' if any(map(str(file_names[i]).__contains__, abnormal_embs)) else 'normal'
data = pd.concat(data,
ignore_index=False, keys=[os.path.splitext(os.path.basename(spec))[0] for spec in file_names],
names=['specimen', 'org'])

line_file = _dir.parent / "full_results.csv"
org_dir = _dir.parent / "organs"
os.makedirs(org_dir, exist_ok=True)
for org in data.index.get_level_values('org').unique():
data[data.index.get_level_values('org') == org].to_csv(str(org_dir) + "/results_" + str(org) + ".csv")




def select_subset(paths, subset_ids):
"""
Trim the files found in the wildtype input directory to thise in the optional subset list file
Expand Down Expand Up @@ -855,7 +911,13 @@ def strip_img_extension(file_name):
return stripped
else:
return file_name

#
# def write_dir_doc(dir_, name, msg):
# """
# Write a log file into an output directory to give user some info on what is in there
# """
# with open(dir_ / name, 'w') as fh:
# fh.write(msg)

def test_installation(app):
try:
Expand Down Expand Up @@ -955,7 +1017,7 @@ def cfg_load(cfg) -> Dict:
"""
There are 2 types of config file used in the project yaml an toml. Will move to al tml at some point

This function wraps around both and helps with
This function wraps around both

Returns
-------
Expand All @@ -968,11 +1030,9 @@ def cfg_load(cfg) -> Dict:

if Path(cfg).suffix == '.yaml':

# If pyyaml version >= 5.1 will get a warning about using explicit loader 'yaml.load(cfg, loader=yaml.Loder)
# But this is OK to ingnore
try:
with open(cfg, 'r') as fh:
return yaml.load(fh)
return yaml.load(fh, Loader=yaml.FullLoader)
except Exception as e:
raise ValueError("can't read the config file - {}".format(e))

Expand Down
6 changes: 3 additions & 3 deletions lama/elastix/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
LOG_FILE = 'inversion.log'
TRANSFORMIX_OUT_NAME = 'result.nrrd'
INVERSION_DIR_NAME = 'Inverted_transform_parameters'
LABEL_INVERTED_TRANFORM = 'labelInvertedTransform.txt'
IMAGE_INVERTED_TRANSFORM = 'ImageInvertedTransform.txt'
PROPAGATE_LABEL_TRANFORM = 'labelInvertedTransform.txt'
PROPAGATE_IMAGE_TRANSFORM = 'ImageInvertedTransform.txt'
VOLUME_CALCULATIONS_FILENAME = "organvolumes.csv"
INVERT_CONFIG = 'invert.yaml'
PROPAGATE_CONFIG = 'propagate.yaml'
REG_DIR_ORDER_CFG = 'reg_order.txt'
RESOLUTION_IMGS_DIR = 'resolution_images' # When reading images from dir and subdirs, ignore images in this folder
TRANSFORMIX_OUT = 'result.nrrd' # This will not be correct if filetype is not nrrd
Expand Down
10 changes: 5 additions & 5 deletions lama/elastix/deformations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


"""
Given a sequence of deformation fields, generate a mean deformation field and jacobian determinant file
Generate jacobians and deformation fields from a LAMA registration run
"""

from lama import common
Expand Down Expand Up @@ -149,7 +149,7 @@ def _generate_deformation_fields(registration_dirs: List,

shutil.copy(elastix_tform_file, temp_transform_file)
transform_params.append(temp_transform_file)
_modfy_tforms(transform_params) # Add the InitialtransformParamtere line
_chain_tforms(transform_params) # Add the InitialtransformParamtere line

else:
# The resolutdeformation_dirion paramter files are numbered from 0 but the config counts from 1
Expand All @@ -166,7 +166,7 @@ def _generate_deformation_fields(registration_dirs: List,
shutil.copy(elastix_tform_file, temp_transform_file)
transform_params.append(temp_transform_file)

_modfy_tforms(transform_params) # Add the InitialtransformParamtere line
_chain_tforms(transform_params) # Add the InitialtransformParamtere line

# Copy the tp files into the temp directory and then modify to add initail transform

Expand All @@ -176,10 +176,10 @@ def _generate_deformation_fields(registration_dirs: List,
return neg_jac_array


def _modfy_tforms(tforms: List):
def _chain_tforms(tforms: List):
"""
Add the initial paramter file paths to the tform files
Wedon't use this now as all the transforms are merged into one by elastix
We don't use this now as all the transforms are merged into one by elastix
:return:
"""
if len(tforms) < 2: # Cannot have initial tform file as we need at least 2
Expand Down
Loading