Skip to content
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

PET/MR Simulation #1007

Open
wants to merge 1,327 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1327 commits
Select commit Hold shift + click to select a range
ffcf18b
Merge branch 'master' of https://github.com/SyneRBI/SIRF into fix-mr-…
Jul 27, 2021
90bb89c
Merge branch 'fix-mr-geometry' into petmr-simulation
Jul 27, 2021
2b0101d
Implemented python tests for simulation in CMake
Jul 27, 2021
197011c
Added Python test to recon simulation test output
Jul 27, 2021
9cbffb3
Updated simulation function to work without motion dynamics
Jul 27, 2021
bb10266
Changed interface of adding dynamics
Jul 27, 2021
1af93e0
Changed location of preprocess c++ function to gadgetron_x
Jul 27, 2021
4a345a9
Ensured ability to run multiple tests from the same file in python tests
Jul 27, 2021
1238724
Added statics and dynamic test for simulation
Jul 27, 2021
ce5ae00
Mock signals now start at t=0
Jul 27, 2021
0155b97
Added second test to recon dynamic simualtion test data
Jul 27, 2021
d5e229d
Renamed simulate_dynamics to simulate_data
Jul 28, 2021
98603dd
Renamed simulate_dynamics to simulate_data
Jul 28, 2021
d96337b
Added test to run simulation with
Jul 28, 2021
6b63f39
Added Python file for simulation and SWIG in CMAKE
Jul 28, 2021
ee5f012
CHanged # of motion states in 5d motion test
Jul 28, 2021
8a71919
added pysimulation package to aliasing
Jul 29, 2021
b68e419
Added time sorting to mock sawtooth signal
Jul 29, 2021
848dfe0
Fixed 5D motion bug
Jul 29, 2021
125efaa
Added recon of 5D test output
Jul 29, 2021
571a963
Changed name of interface funtion for dyn sim construcotr
Jul 29, 2021
67ebe1f
Got working Python constructor for simulation
Jul 29, 2021
b6ad633
Wrapped setter for template acquisitions
Jul 29, 2021
7839a17
Updated test for recon of simulation data
Jul 29, 2021
2d29816
Wrapped everything necessary for a static simulation
Jul 29, 2021
9812fb7
Modified test to simulate static random tissues
Jul 29, 2021
ea51059
Added single dvf addition to motion dynamics
Jul 30, 2021
dd5f296
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
Jul 30, 2021
f46a540
Included stddef header to allow size_t defines
Jul 30, 2021
30de60e
Switched location of the header for size_t declaration
Jul 30, 2021
ca13617
Added test for MR simulations in python
Jul 30, 2021
9616b56
Deleted test for individual mr simulations
Jul 30, 2021
93266b5
Continued wrapping of dynamics
Jul 30, 2021
886d746
Renamed aMRDynamic to MRDynamic
Jul 30, 2021
7f03816
Changed interface of bin_mr_acquisisionts
Jul 30, 2021
06832f9
Wrappend binning of acuisitions
Jul 30, 2021
9fcc88d
Fixed bug
Jul 30, 2021
c28b51f
Updated test to pass sources for dvf correctly
Jul 30, 2021
5075af0
Got running test for dyn mo sim but output is empyt
Jul 30, 2021
1ed79c9
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
Aug 17, 2021
a7c65a7
Added constness of passed surrogate signal to setter
Aug 17, 2021
d718b52
fixed type for setting up surrogate signal
Aug 17, 2021
747a237
fixed typoe error after merge
Aug 17, 2021
5842aa8
extended mr simulation test
Aug 17, 2021
dd6efb5
Added test for c-interface from C++
Aug 18, 2021
f2f8a02
changed bin number to type unsinged
Aug 18, 2021
75f60f9
Added getter for num ber of signal points in python
Aug 18, 2021
28baa57
Added test for setter for dynamic signal
Aug 18, 2021
a21a21a
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
Aug 19, 2021
7f025a8
Took care of merge fallout
Aug 19, 2021
a7d4f7b
Renamed aPETDynamic to PETDynamic
Aug 20, 2021
844c415
Added signal and bin processors
Aug 20, 2021
846f59c
Deleted uncesseray method
Aug 20, 2021
12a35c3
Switched tests to test processors
Aug 20, 2021
33480e3
Shifted whole functionality of dynamic into new class
Aug 20, 2021
4a9f981
Updated method name
Aug 20, 2021
3555fbd
Updated method name
Aug 20, 2021
9ddfed0
Updated dynamics classes
Aug 20, 2021
f2daae2
Renamed the motoin dynamics to processors
Aug 20, 2021
c4cac3c
COntinued change of interface
Aug 20, 2021
edae1ea
Changed namespaces for dynamcis test
Aug 23, 2021
58eb163
did nothing practically
Aug 23, 2021
3fd31ce
New dynamic interface
Aug 23, 2021
f9bb51c
Brougth new interface to compile
Aug 23, 2021
1ad948b
Updated python to new inheritance scheme
Aug 23, 2021
7512894
fixed segfault by making methods virtual
Aug 23, 2021
269de69
Updated tests to write niftis
Aug 23, 2021
1a2b2d7
Renamed for recon to run after smuilation
Aug 23, 2021
3461547
Deleted redundant function
Aug 23, 2021
f01d370
deleted comment blocks
Aug 23, 2021
e9a03ab
Added storing of GT to python tests
Aug 23, 2021
47c0011
Added C test to convert input data from h5 into nii
Aug 23, 2021
2045673
Added example for patientdata simulation
Aug 24, 2021
0456b46
Extended example to recon data on the fly
Aug 24, 2021
b55e744
Renamed variable in python test
Aug 24, 2021
e7328a8
Finalised 3D cartesian example
Aug 24, 2021
f1503b5
Switched to time unit of secodns
Aug 25, 2021
f433bf1
udpated tests
Aug 25, 2021
1631c48
Renamed variabels with time unit suffix
Aug 25, 2021
dfe9d85
Switched to settingg dynamics rawdata inside the simulation
Aug 25, 2021
2bde574
Updated test
Aug 25, 2021
69b2bd9
Added some comments to clarify function outcome
Aug 25, 2021
3d6e2db
added dynsim deformer memeber to simulation
Aug 25, 2021
a42edd1
Enabled setting template image in deformer
Aug 25, 2021
91777a3
Deleted access to setter of rawdata for dynamics
Aug 25, 2021
8959d38
Differentiation between acquisition and contrast rawdata
Aug 26, 2021
32977f3
Corrected segfault for wrong calls in dynsim deformer
Aug 26, 2021
b13f97c
Updated test for new interface
Aug 26, 2021
ef605c0
Added setter for images in contrastgenerator
Aug 26, 2021
2d7aaee
Added test for geometry and transfnormations for siulation data
Aug 26, 2021
82e34e7
Updated simualtion example to work with diff sets of acquisition data
Aug 26, 2021
73cfd16
Added shift in z-direction to transformations during rawdata acquiistion
Aug 26, 2021
e41c334
Compute CSM based on acquisition template rawdata
Aug 26, 2021
332a7fd
Swtiched to affine transform to compute offset in dynsim deformer
Aug 26, 2021
2fc8831
Added interface to pass external affine trafo to simultion
Aug 27, 2021
8d65e14
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
Aug 27, 2021
6893b1e
Merge branch 'fix-afftrafo-constructor' into petmr-simulation
Aug 27, 2021
6d201e6
Merge branch 'fix-afftrafo-constructor' into petmr-simulation
Aug 27, 2021
2bf7a92
Fixed interface for passing offset trafo to simulation
Aug 27, 2021
551e5cb
Added euler parameters to python example
Aug 27, 2021
91b157b
Deleted commented line
Aug 27, 2021
4595857
Merge branch 'radial-2D-encoding' into petmr-simulation
Aug 31, 2021
0a6bcdf
Added reorientation of MR volumes into segmentation after contrast ge…
Sep 1, 2021
ec149e3
Added resampling into template acquisition image without motionfields
Sep 1, 2021
dee2cef
Making subset with the appropriate acuqisitions info
Sep 1, 2021
f43716b
added some try_callings to catch exceptions
Sep 1, 2021
9fb5267
Added special case to deformer when nothing moves
Sep 1, 2021
7719651
Added radial option to simulation
Sep 1, 2021
64ba984
Merge branch 'radial-2D-encoding' into petmr-simulation
Sep 6, 2021
35cd062
Merge branch 'master' of https://github.com/SyneRBI/SIRF into fix-mr-…
Sep 23, 2021
7df20a3
Deleted obsolete test
Sep 23, 2021
f389a9f
Updated comment
Sep 23, 2021
2c49585
Added check for float tolerance instead of == comparison
Sep 23, 2021
aa77667
Merge branch 'master' of https://github.com/SyneRBI/SIRF into fix-mr-…
Oct 20, 2021
6cd8ca0
Updated comment
Oct 20, 2021
83d6011
Merge branch 'radial-2D-encoding' into petmr-simulation
Oct 21, 2021
b903c7a
Merge branch 'fix-mr-geometry' into petmr-simulation
Oct 21, 2021
1c46c84
Added external contrast member to contrast generator
Oct 21, 2021
b83376c
Made getter function const in tissue label mapper
Oct 21, 2021
2511979
Wrote mock external signal generator
Oct 21, 2021
6dc7443
Wrote test for external signal contrast mapping
Oct 21, 2021
7f90d31
Provided interface to map signal based on external input in mr contrast
Oct 21, 2021
34fbe0e
Refactored motion-contrast simualtion loop
Oct 26, 2021
ad4e4e0
Added external contrast dynamics class
Oct 26, 2021
e282b0d
did some whitespace/tabs cleanup
Oct 26, 2021
9133b0b
Added function to motiondynamics to get mvf at timepoint
Oct 27, 2021
7eba8b3
Added test to run external contrast simulation on C++
Oct 27, 2021
c1d3593
Added compiling version of simulating external contrast signals
Oct 27, 2021
9922df9
fixed bug for missing return
Oct 27, 2021
819284f
Added missing binning of external acquisitions
Oct 27, 2021
984be53
Fixed problem of not finding binned acuqisitions
Oct 28, 2021
6d17c46
Merge branch 'master' of https://github.com/SyneRBI/SIRF into add-ext…
Oct 28, 2021
ce553ea
Corrected accessing error on acquisition vector
Oct 28, 2021
18e1d0f
Added function to push back single signal timepoint
Nov 3, 2021
889b587
Started implementing the external dynamic class in python
Nov 3, 2021
008c93b
started adding c glue code for external contrast variations
Nov 3, 2021
fd43556
Added test for external contrast dynamics
Nov 4, 2021
5991c54
added helper class for python external signals
Nov 4, 2021
9d331e0
Wrapped external signal into c
Nov 4, 2021
04d5772
Updated test to use external contrast signal
Nov 4, 2021
e38de5d
Added recon of simulation data as addition to test
Nov 4, 2021
db59edc
Renamed method
Nov 5, 2021
5734cbb
Renamed method
Nov 5, 2021
39d841f
Added parallel code in contrast mapping
Nov 5, 2021
5fae741
Updated test to use XCAT
Nov 5, 2021
eb38f34
Improved usability of example for 2d from 3d simulation
Nov 15, 2021
9f377ae
Merge branch 'add-ext-contrast' into petmr-simulation
Jan 3, 2022
69708ce
Started wrapping contrast dynamics into simulation
Jan 3, 2022
b3304b8
running version of contrast dynamics with bug in binning
Jan 3, 2022
bebd168
Changed to non-static contrast dynamic members
Jan 3, 2022
bb83a74
Cleaned up debuggin
Jan 3, 2022
0f1ddc4
Added method to discard data in acquisition object
Jan 5, 2022
bf15e50
Added method to discard data in acquisition object
Jan 5, 2022
0a9e952
Added reconstruction to python test
Jan 5, 2022
ecb1311
Reforamtting
Jan 5, 2022
cc1a7d6
switched of pragma parallels
Jan 5, 2022
783625c
Enabled setting of spin density for tissue parameters
Jan 5, 2022
e4f1931
Corrected contrast simulation for wrong time scaling (sec instead of ms)
Jan 7, 2022
884bf7c
Renamed temporary variables in loop
Jan 7, 2022
3fca946
Added simulation demo for non-cubic phantom
johannesmayer Jan 20, 2022
d369b73
Added example for external contrast
johannesmayer Jan 31, 2022
e05a680
Trigger GHA workflow
johannesmayer Jan 31, 2022
5a26ea8
Added code to parse tissue XML from Python
johannesmayer Feb 1, 2022
52712a6
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Feb 1, 2022
39318ee
Leftover from merge
johannesmayer Feb 1, 2022
410ab00
Added prep script to examples to extract mr parameters from XML
johannesmayer Feb 2, 2022
af4ca23
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Feb 2, 2022
650134c
Added script to simulate static mrf
johannesmayer Feb 2, 2022
4b993c7
Merge branch 'fix-subset-access' into petmr-simulation
johannesmayer Feb 2, 2022
2006c00
Updated example for external contast to have MRF
johannesmayer Feb 2, 2022
d01aa25
Added test and interface for saving groudn truth parameters maps
johannesmayer Feb 2, 2022
310689a
Added test for contrast generator mapping tissue parameters
johannesmayer Feb 2, 2022
1a961ce
updated test for new output class of images
johannesmayer Feb 2, 2022
8a47c38
Finished contrast generator parameter map creation
johannesmayer Feb 2, 2022
3d5ca1c
renamed function
johannesmayer Feb 3, 2022
acc459e
Added writing to dynamic simulation interface without resampling
johannesmayer Feb 3, 2022
4ae5d67
Added resampling into template coordinates to parameter maps groudn t…
johannesmayer Feb 3, 2022
43b903b
deleted useless line
johannesmayer Feb 3, 2022
c9ae9e5
Added test to check 2d resampling
johannesmayer Feb 3, 2022
c9e2a8d
Wrapped gr writer in python
johannesmayer Feb 3, 2022
19f224b
Deleting temporary files before creating as ISMRMRD appends to files
johannesmayer Feb 4, 2022
855024a
Merge branch 'fix-tempfile-overflow' into petmr-simulation
johannesmayer Feb 4, 2022
a514c68
Merge branch 'fix-deserialize-call' into petmr-simulation
johannesmayer Feb 4, 2022
70d7621
Added example for geometry
johannesmayer Feb 4, 2022
8c3bf96
Deleted unused code from deformer
johannesmayer Feb 7, 2022
d669d60
Updated example scripts
johannesmayer Feb 7, 2022
4884ee3
ensure that position is also set to zero
johannesmayer Feb 7, 2022
1b5a312
Deleted junk code in contrast generator
johannesmayer Feb 7, 2022
ef31af4
[ci skip] Updated examples for geometry
johannesmayer Feb 7, 2022
9756ff7
added example script for 3D RPE
johannesmayer Feb 11, 2022
469d383
[ci skip] Continued work on geometry of simulation erxample
johannesmayer Feb 15, 2022
5f7e661
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Feb 21, 2022
d032157
[ci-skip] return filenames of parametric maps of ground truth
johannesmayer Feb 23, 2022
c4a4fcf
Calls warning if template acquisition is not set
johannesmayer Feb 23, 2022
bffc423
Calls warning if template acquisition is not set
johannesmayer Feb 23, 2022
cbb9700
Updated norming of acquisition orientation
johannesmayer Feb 23, 2022
55cb126
Added test for C++ mr geometry
johannesmayer Feb 23, 2022
f043013
rewrote dynsim deformer test to minimal geometry example
johannesmayer Feb 24, 2022
0bcea11
Modification of acquisition header with segmentation dimensions:
johannesmayer Feb 24, 2022
8c21a7a
Added the acquisition setter function
johannesmayer Feb 25, 2022
c95ba42
Added setter for acquisition parameter in c
johannesmayer Feb 25, 2022
d07ee4b
Added setter for acquisition index variables in python
johannesmayer Feb 25, 2022
8ee8554
Corrected typo
johannesmayer Feb 25, 2022
d433293
Merge branch 'master' of https://github.com/SyneRBI/SIRF into add-acq…
johannesmayer Feb 25, 2022
bf0088d
Merge branch 'add-acquisition-setter' into petmr-simulation
johannesmayer Feb 25, 2022
d016a77
ensured passing of data types for snr is correct
johannesmayer Mar 1, 2022
ff8ace0
Passing the SNR as a float parameter
johannesmayer Mar 1, 2022
1519b2f
Added outputs for noise labels
johannesmayer Mar 1, 2022
c2e8e53
Changed noise label data tyhpe from size_t to int
johannesmayer Mar 1, 2022
0bd675b
ending program if contrast template is not set yet in generator
johannesmayer Mar 1, 2022
4b8112d
[ci skip] Had to ste the acquisition after you add the noise
johannesmayer Mar 1, 2022
f3adc77
[ci skip] Cleaned up a bit
johannesmayer Mar 1, 2022
5c50b72
[ci-skip] Replaced wrong command for vector clearance
johannesmayer Mar 2, 2022
8fb6d26
Fixed bug for signal == 1 in cyclic dynamics
johannesmayer Mar 3, 2022
83d25bf
[ci skip] Added set template function that sets both types simultaneo…
johannesmayer Mar 14, 2022
abda270
Added idx_corr to the dynamics class
johannesmayer Mar 15, 2022
c7599c0
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Mar 15, 2022
73d1106
[ci skip] Empty the acquisitions prior to motion binning
johannesmayer Mar 15, 2022
1a4c2f1
[ci skip]Added interface to get idx_corr. Problem with output, large …
johannesmayer Mar 15, 2022
a380ed4
[ci skip]Implemented return of idx_corr for MR Dynamics objects
johannesmayer Mar 16, 2022
e3ac2d4
[ci skip] Updated test and cleared output
johannesmayer Mar 16, 2022
4848558
[ci skip] Updated test and cleared output
johannesmayer Mar 16, 2022
122bdc4
Changed time unit for external contrast
johannesmayer Mar 23, 2022
b6d7159
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Mar 24, 2022
786be3a
enable getting list of names associated with the labels
johannesmayer Mar 24, 2022
a235eda
Added option to return labels
johannesmayer Mar 29, 2022
144b4dd
Added displacement offset in dynsim deformer
johannesmayer Mar 29, 2022
3b9450f
Added option to compute average surrogate signal
johannesmayer Mar 29, 2022
2be642f
Storing labels as parameter ground truth
johannesmayer Mar 29, 2022
4a778d3
Updated tests for avg surrogate and vector ifelds
johannesmayer Mar 29, 2022
d4c49d3
Added assertion to make sure we have a signal before interpolationg
johannesmayer Mar 29, 2022
08fad2e
Added average motion fields to gt offsetl
johannesmayer Mar 29, 2022
686595f
Removed reorient for dispalcement fields. this is usually applied to …
johannesmayer Mar 29, 2022
315c40e
Removed reorient for dispalcement fields. this is usually applied to …
johannesmayer Mar 29, 2022
633ba7a
made avg surrogate isgnal function Virtual
johannesmayer Mar 29, 2022
f2ca118
Added non-nearestneightbor reasmpler for labels
johannesmayer Mar 30, 2022
fb599e3
[ci skip] deleted unused function
johannesmayer May 23, 2022
2c207e8
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer May 23, 2022
5177e7b
Used typedef for datatype
johannesmayer May 23, 2022
8c0beb8
[ci skip] Added documentation to dynamics
johannesmayer May 23, 2022
2b46879
[ci skip] Added documentation
johannesmayer May 23, 2022
b2df2ce
[ci skip] Added documentation
johannesmayer May 24, 2022
66ddca5
[ci skip] deleted comment
johannesmayer May 24, 2022
00aaf3b
Deleted old includes
johannesmayer May 24, 2022
c9ed355
[ci skip] put dynsim deformer into namespace sirf
johannesmayer May 24, 2022
8c86d42
[ci skip] Put dynamics into namespace sirf
johannesmayer May 24, 2022
3ef5377
Merge branch 'master' of https://github.com/SyneRBI/SIRF into petmr-s…
johannesmayer Jun 14, 2022
e6a876f
[ci skip] Added Documentation to python interface
johannesmayer Jun 14, 2022
ac09847
Printing info for only 100th line for external contrast simulations
johannesmayer Jun 27, 2022
0745b7e
[ci skip] Suppressing SIRF Reg cout put
johannesmayer Jun 27, 2022
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: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
src/xDynamicSimulation/cDynamicSimulation/Testing/tests_dynamicsimulation.h merge=ours
src/xDynamicSimulation/cDynamicSimulation/Testing/tests_dynamicsimulation.cpp merge=ours
src/xGadgetron/cGadgetron/gadgetron_data_containers.h merge=ours
src/xGadgetron/cGadgetron/gadgetron_data_containers.cpp merge=ours
Comment on lines +1 to +4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need this? seems weird to keep it on master.

13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

# CMake
*.cmake
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely not ignore those! We have them our own

*.make
*.include_cache
*.internal
# User-specific files
*.suo
*.user
Expand All @@ -20,6 +25,14 @@ bld/
[Bb]in/
[Oo]bj/

# CMake
CMakeCache.txt
CMakeFiles*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aargh. ignore CMakeFiles.txt ?

I think you're trying to ignore files because you did an "in-source" build, which isn't recommended in any case.


# Makefiles
**/Makefile*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

who knows, maybe we have some valid ones at some point



# Roslyn cache directories
*.ide/

Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ else()
endif()
option(SIRF_INSTALL_DEPENDENCIES "Install dlls etc" ${DEFAULT_SIRF_INSTALL_DEPENDENCIES})
####### CMake path
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_LIST_DIR}/cmake")

# If OSX give the advanced option to use absolute paths for shared libraries
if (APPLE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ what was found/built:
[style-badge]: https://api.codacy.com/project/badge/Grade/392861b4085f4f438d12c41029f86b47
[style-link]: https://www.codacy.com/gh/SyneRBI/SIRF?utm_source=github.com&utm_medium=referral&utm_content=SyneRBI/SIRF&utm_campaign=Badge_Grade
[zenodo-badge]: https://zenodo.org/badge/DOI/10.5281/zenodo.2707911.svg
[zenodo-link]: https://doi.org/10.5281/zenodo.2707911
[zenodo-link]: https://doi.org/10.5281/zenodo.2707911
6 changes: 6 additions & 0 deletions cmake/setup.py.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ if(BUILD_PYTHON)
python_pkg_alias(pyiutilities "sirf.pyiutilities")
python_pkg_alias(pReg "sirf.Reg")
python_pkg_alias(pyreg "sirf.pyreg")
python_pkg_alias(pysimulation "sirf.pysimulation")
# convert to python CSV tuple for setup.py configure_file
string(REPLACE ";" "', '" PYTHON_SETUP_PKGS_CSV "${PYTHON_SETUP_PKGS}")
set(PYTHON_SETUP_PKGS_CSV "'${PYTHON_SETUP_PKGS_CSV}'")
Expand All @@ -42,8 +43,13 @@ if(BUILD_PYTHON)
if(PYTHONINTERP_FOUND)
# python setup.py install
if("${PYTHON_STRATEGY}" STREQUAL "SETUP_PY")
message("intalling setup.py")
install(CODE "execute_process(COMMAND\n\
<<<<<<< HEAD
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

conflict marker

\"${PYTHON_EXECUTABLE}\" setup.py install --prefix ${PYTHON_DEST}\n\
=======
\"${Python_EXECUTABLE}\" setup.py build install\n\
>>>>>>> rpe-encoding
WORKING_DIRECTORY \"${PYTHON_DEST}\")")
endif()
endif(PYTHONINTERP_FOUND)
Expand Down
26 changes: 26 additions & 0 deletions examples/Python/Simulation/prepare_EPG_input.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import sys
sys.path.append("/home/sirfuser/devel/buildVM/sources/SIRF/src/xDynamicSimulation/pDynamicSimulation/")

import numpy as np

import TissueParameterList as TPL

root_path = '/media/sf_CCPPETMR/TestData/Input/xDynamicSimulation/pDynamicSimulation/'
xml_path = root_path + 'Cube128/XCAT_TissueParameters_XML.xml'
fpath_output = root_path + 'Fingerprints/XCAT_tissue_parameter_list.npz'


# parse file
tpl = TPL.TissueParameterList()
tpl.parse_xml(xml_path)
tpl.print_contents()

# prepare EPG input array
all_mr_params = tpl.mr_as_array()
mr_params = all_mr_params[:,1:]
mr_params[:,0] /= 100
mr_params[:,-1] = 0

mr_params_unique,idx_inverse = np.unique(mr_params, axis=0, return_inverse=True)

np.savez(fpath_output, mr_params_full=all_mr_params, mr_parameters=mr_params_unique, unique_idx_inverse=idx_inverse)
51 changes: 51 additions & 0 deletions examples/Python/Simulation/preprocess_speedup_testdata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

import numpy as np
from pathlib import Path
import nibabel as nib



num_slices = 10
Nz = 128
slab_start = Nz//2 -num_slices//2
slab_end = Nz//2 + num_slices//2


def preprocess_mvfs(rootpath, folder_pattern, prefix_output):

fpath_input = Path(rootpath + folder_pattern)
print("looking in {} ".format(fpath_input))
list_files = sorted(fpath_input.glob('mvf_*'))

for f in list_files:
print("loading {}".format(f))

mvf = nib.load(str(f))
print("The input motoinfield has size {}".format(mvf.shape))

mvf = mvf.slicer[:,:,slab_start:slab_end,:]
print("The output motoinfield has size {}".format(mvf.shape))

fname_output = str(prefix_output + folder_pattern + f.name)
print("Storing to {}".format(fname_output))
nib.save(mvf, fname_output)

root_path = '/media/sf_CCPPETMR/TestData/Input/xDynamicSimulation/pDynamicSimulation/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hard-coded


fpath_input = root_path + 'Cube128/'
fpath_output = root_path + 'Slab128/'

foldername_resp = 'mvf_resp/'
foldername_card = 'mvf_card/'

preprocess_mvfs(fpath_input, foldername_resp, fpath_output)
preprocess_mvfs(fpath_input, foldername_card, fpath_output)


fname_segmentation = fpath_input + 'label_volume.nii'
seg = nib.load(fname_segmentation)

print("The input segmentation has size {}".format(seg.shape))

seg = seg.slicer[:,:,slab_start:slab_end]
nib.save(seg, fpath_output + 'label_volume.nii')
185 changes: 185 additions & 0 deletions examples/Python/Simulation/simulate_3D_RPE.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
'''
bla bla

Usage:
cartesian_3D_simulation.py [--help | options]

Options:
--non-interactive do not show plots
'''

## SyneRBI Synergistic Image Reconstruction Framework (SIRF).
## Copyright 2015 - 2020 Rutherford Appleton Laboratory STFC.
## Copyright 2015 - 2017 University College London.
## Copyright 2015 - 2017 Physikalisch-Technische Bundesanstalt.
##
## This is software developed for the Collaborative Computational
## Project in Synergistic Reconstruction for Biomedical Imaging (formerly CCP PETMR)
## (http://www.ccpsynerbi.ac.uk/).
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
## http://www.apache.org/licenses/LICENSE-2.0
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.

__version__ = '0.1.0'
from docopt import docopt

args = docopt(__doc__, version=__version__)

from pUtilities import *
import sirf.Reg as pReg
import sirf.DynamicSimulation as pDS
import sirf.Gadgetron as pMR

# import engine module

# process command-line options
show_plot = not args['--non-interactive']

from pathlib import Path
import numpy as np
import time


def read_motionfields(fpath_prefix):
p = sorted( Path(fpath_prefix).glob('*.nii') )
files = [x for x in p if x.is_file()]

temp = []
for f in files:
print("Reading from {} ... ".format(f))
img = pReg.NiftiImageData3DDisplacement(str(f))
temp.append(img)

data = np.array(temp, dtype=object)
return data

def set_motionfields_from_path(modyn, fpath_prefix):

assert_validity(modyn, pDS.MRMotionDynamic)
mvfs = read_motionfields(fpath_prefix)

for m in mvfs:
modyn.add_displacement_field(m)


def get_normed_surrogate_signal(t0_s, tmax_s, Nt, f_Hz):

t_s = np.linspace(t0_s, tmax_s, Nt)
sig = 0.5 * (1 + np.sin( 2*np.pi*f_Hz*t_s))
return t_s, sig


def main():

fpath_testdata_prefix = '/media/sf_CCPPETMR/TestData/'
input_fpath_prefix = fpath_testdata_prefix + 'Input/xDynamicSimulation/pDynamicSimulation/'
output_fpath_prefix = fpath_testdata_prefix + 'Output/xDynamicSimulation/pDynamicSimulation/'

fpath_xml = input_fpath_prefix + 'Cube128/XCAT_TissueParameters_XML.xml'

fpath_template_contrast_rawdata = input_fpath_prefix + 'Cube128/CV_nav_cart_128Cube_FLASH_T1_defaultorient.h5'
fpath_template_acquisition_rawdata = input_fpath_prefix + 'General/meas_MID00241_FID69145_Tho_T1_fast_ismrmrd_defaultorient.h5'

acquisition_ad = pMR.AcquisitionData(fpath_template_acquisition_rawdata)
acquisition_ad = pMR.set_grpe_trajectory(acquisition_ad)

# configure the simulation
contrast_ad = pMR.AcquisitionData(fpath_template_contrast_rawdata)
contrast_ad = pMR.preprocess_acquisition_data(contrast_ad)

labels = pReg.NiftiImageData3D( input_fpath_prefix + "Cube128/label_volume_rai.nii" )
mrsim = pDS.MRDynamicSimulation(labels, fpath_xml)

mrsim.set_contrast_template_data(contrast_ad)
mrsim.set_acquisition_template_data(acquisition_ad)

offset_z_mm = 0
translation = np.array([0, 0, offset_z_mm])
euler_angles_deg = np.array([0,0,0])

offset_trafo = pReg.AffineTransformation(translation, euler_angles_deg)
mrsim.set_offset_trafo(offset_trafo)

# take CSM from the rawdata itself
# could be replaced if independent way of computing CSM is available
csm = pMR.CoilSensitivityData()
csm.calculate(acquisition_ad)
mrsim.set_csm(csm)

# set which tissue defines SNR
SNR = 10
SNR_label = 13

mrsim.set_snr(SNR)
mrsim.set_snr_label(SNR_label)

# configure the surrogates
Nt = 10000
t0_s = 0
tmax_s = 60* 5


f_Hz_resp = 0.2

t_resp, sig_resp = get_normed_surrogate_signal(t0_s, tmax_s, Nt, f_Hz_resp)


# configure the motion
num_motion_states = 4
# RESP
num_sim_resp_states = num_motion_states
# resp_motion = pDS.MRMotionDynamic( num_sim_resp_states )
# resp_motion.set_dynamic_signal(t_resp, sig_resp)
# resp_motion.set_cyclicality(False)
# resp_motion.set_groundtruth_folder_prefix(output_fpath_prefix + "output_simulation_3D_motiondata_r_{}_gt_resp".format(num_sim_resp_states))
# set_motionfields_from_path(resp_motion, input_fpath_prefix + 'Cube128/mvf_resp/')
# mrsim.add_motion_dynamic(resp_motion)

#
fname_simulation_output = "output_simulation_3DRPE_motiondata_traj_r{}".format(num_sim_resp_states)

fname_output = output_fpath_prefix + fname_simulation_output + ".h5"
simulated_file = Path(fname_output)
if not simulated_file.is_file():

tstart = time.time()
mrsim.simulate_data()
print("--- Required {} minutes for the simulation.".format( (time.time()-tstart)/60))
mrsim.write_simulation_results(str(simulated_file))
else:
print("Skipping simulation since output file already exists.")

# mrsim.save_motion_ground_truth()

simulated_data = pMR.AcquisitionData(str(simulated_file))

csm.calculate(simulated_data)

AM = pMR.AcquisitionModel()
AM.set_coil_sensitivity_maps(csm)
AM.set_up(simulated_data, csm)

recon_img = AM.inverse(simulated_data)
recon_nii = pReg.NiftiImageData3D(recon_img)
recon_nii = recon_nii.abs()

fname_output = output_fpath_prefix + "recon_" + fname_simulation_output + ".nii"
recon_nii.write(fname_output)

return 1

try:
main()
print('\n=== done with %s' % __file__)

except error as err:
# display error information
print('??? %s' % err.value)
exit(1)
Loading