-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parametrized the algorithm names in the testing. Made the search for …
…algorithm files a little more robust.
- Loading branch information
1 parent
b965d51
commit bb79fc3
Showing
3 changed files
with
71 additions
and
50 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
tests/IVIMmodels/unit_tests/simple_test_run_of_algorithm.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import numpy as np | ||
import os | ||
from pathlib import Path | ||
from src.standardized.ETP_SRI_LinearFitting import ETP_SRI_LinearFitting | ||
from src.standardized.IAR_LU_biexp import IAR_LU_biexp | ||
|
||
## Simple test code... | ||
# Used to just do a test run of an algorithm during development | ||
def test_run(model, **kwargs): | ||
bvalues = np.array([0, 200, 500, 800]) | ||
|
||
def ivim_model(b, S0=1, f=0.1, Dstar=0.03, D=0.001): | ||
return S0*(f*np.exp(-b*Dstar) + (1-f)*np.exp(-b*D)) | ||
|
||
signals = ivim_model(bvalues) | ||
|
||
#model = ETP_SRI_LinearFitting(thresholds=[200]) | ||
if kwargs: | ||
results = model.osipi_fit(signals, bvalues, **kwargs) | ||
else: | ||
results = model.osipi_fit(signals, bvalues) | ||
print(results) | ||
#test = model.osipi_simple_bias_and_RMSE_test(SNR=20, bvalues=bvalues, f=0.1, Dstar=0.03, D=0.001, noise_realizations=10) | ||
|
||
model1 = ETP_SRI_LinearFitting(thresholds=[200]) | ||
model2 = IAR_LU_biexp() | ||
|
||
test_run(model1, linear_fit_option=True) | ||
test_run(model2) | ||
|
||
########################################### | ||
|
||
path = Path(__file__).resolve().parents[3] # Move up to the root folder | ||
path_standardized_algortihms = path / "src" / "standardized" # Move to the folder containing the algorithms | ||
algorithms = os.listdir(path_standardized_algortihms) # Get the contents of the folder | ||
|
||
# Remove some crap | ||
algorithms.remove("__init__.py") | ||
algorithms.remove("__pycache__") | ||
algorithms.remove("template.py") | ||
|
||
# Remove the .py extensions from the algorithms names | ||
algorithms = [algorithm.split(".")[0] for algorithm in algorithms] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.