Skip to content

Add import/export of dataclasses to hdf5-based mrp files#766

Open
fzimmermann89 wants to merge 12 commits intomainfrom
gh/fzimmermann89/84/head
Open

Add import/export of dataclasses to hdf5-based mrp files#766
fzimmermann89 wants to merge 12 commits intomainfrom
gh/fzimmermann89/84/head

Conversation

@fzimmermann89
Copy link
Copy Markdown
Member

@fzimmermann89 fzimmermann89 commented Apr 4, 2025

Draft of a more efficient "mrpro native" data format matching our dataclass structure.
So instead of acquisitions as in ismrmrd, we write kdata.data, kdata.traj, etc as h5 groups.
This allows us to only store what we actually need in reduced form, speeds up loading for use in trainings and will allow us to store additional information not in ismrmrd.

The idea is to use this for temporary storage and caching. So one can load in all ismrmrd fileds required for a training, dump them to a temp drive and load randomly back into memory in a data loader..

fzimmermann89 added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: ef570f0
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 4, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
src/mrpro
   _version.py6267%7–8
src/mrpro/algorithms/csm
   inati.py25196%43
src/mrpro/algorithms/dcf
   dcf_voronoi.py55493%15, 55–56, 89
src/mrpro/algorithms/optimizers
   adam.py30680%108, 125–129
   cg.py52198%139
   pdhg.py81396%180–181, 187
   pgd.py53492%108, 153–156
src/mrpro/algorithms/reconstruction
   DirectReconstruction.py28679%62, 65, 70, 77–79
   IterativeSENSEReconstruction.py13192%79
   Reconstruction.py501374%54–56, 80–87, 109, 112
   RegularizedIterativeSENSEReconstruction.py512649%104–108, 122–161
   TotalVariationRegularizedReconstruction.py522552%99–111, 125–153
src/mrpro/data
   AcqInfo.py165796%49, 56, 134–135, 137, 243, 367
   CsmData.py43295%233–235
   Dataclass.py4374689%71, 332, 348, 414, 472–474, 487, 582, 602–603, 605, 620–621, 623, 670–671, 676–677, 760–761, 781–782, 794, 799–800, 809, 813–814, 823, 828, 833–834, 840, 847–848, 881, 885, 895, 1033–1034, 1059, 1066, 1071–1072, 1074
   DcfData.py33197%62
   EncodingLimits.py97397%37, 127, 130
   IData.py1781293%138, 155–156, 217–225, 258, 304, 322
   IHeader.py174895%49, 98–101, 284, 288, 292, 296
   KData.py2292490%121–122, 137, 144, 155–166, 177, 185, 196, 234, 256–258, 305–306, 378, 544, 546, 618
   KHeader.py1761393%115–121, 148, 196, 203–204, 231–238
   KNoise.py22195%44
   KTrajectory.py95397%163, 165, 185
   QData.py32197%43
   Rotation.py7434294%105, 203, 340, 438, 482, 500, 587, 589, 598, 635, 637, 700, 777, 782, 785, 800, 817, 822, 898, 1086, 1091, 1094, 1118, 1122, 1146, 1266, 1268, 1276–1277, 1341, 1423, 1627, 1634–1636, 1695, 1791, 1943, 1978, 1982, 2161, 2189
   SpatialDimension.py1501987%34, 103, 146, 158, 278–280, 293–295, 329, 347, 360, 373, 386, 399, 408–409, 437
src/mrpro/data/traj_calculators
   KTrajectoryCalculator.py26292%84, 95
   KTrajectoryCartesian.py31487%129–132, 136
   KTrajectoryIsmrmrd.py19195%57
   KTrajectorySpiral2D.py571377%63–66, 69, 71, 73, 75, 77, 105, 107, 134–136
src/mrpro/operators
   AveragingOp.py36294%72, 113
   CartesianSamplingOp.py112496%152, 191, 266, 387
   ConjugateGradientOp.py89792%62, 64, 100, 106, 228, 230, 233
   ConstraintsOp.py85495%78, 80, 250, 255
   EndomorphOperator.py28293%71, 77
   FiniteDifferenceOp.py29293%40, 126
   FourierOp.py101694%186–187, 206, 251, 315, 320
   Functional.py70297%116, 118
   GridSamplingOp.py1651591%72–73, 82–83, 90–91, 94, 96, 98, 282, 290–291, 306, 312–313
   LinearOperator.py202697%217, 255, 296, 305, 313, 330
   LinearOperatorMatrix.py1741989%99, 136, 169, 178, 183, 192–195, 208–211, 219–220, 225–226, 238, 347, 377, 404
   MultiIdentityOp.py16288%58, 63
   NonUniformFastFourierOp.py1951095%68, 95, 217, 219, 257, 259, 336, 393, 467, 472
   Operator.py88397%82, 115, 125
   PatchOp.py49394%93, 129, 144
   ProximableFunctionalSeparableSum.py44393%118, 213, 224
   SliceProjectionOp.py1781094%45, 62, 64, 70, 154, 180, 216, 253, 290, 330
   WaveletOp.py121596%168, 186, 230, 235, 258
   ZeroPadOp.py18194%30
src/mrpro/operators/functionals
   SSIM.py73790%60–80, 82, 86, 114, 147
src/mrpro/operators/models
   EPG.py2551993%31–32, 283, 288, 304–306, 326–327, 332, 356, 361, 386, 391, 546, 600, 739, 756, 783
src/mrpro/phantoms
   EllipsePhantom.py43295%66, 131
   brainweb.py2974087%276, 290–294, 349–359, 398, 454–457, 479–480, 485–486, 488–489, 493, 501, 508–509, 550, 621, 624–625, 644, 653–656, 667, 669, 700–701, 715, 723
   fastmri.py1061091%50–51, 59, 65, 162, 169–171, 174–175, 189
   m4raw.py74495%58–59, 74, 76
   mdcnn.py71790%58, 62–63, 70, 82, 88, 135
src/mrpro/utils
   RandomGenerator.py1561590%23–24, 36, 38, 188, 212, 428, 446, 528, 799, 829–832, 895, 898
   ema.py42490%49, 74, 78, 82
   filters.py62297%44, 49
   indexing.py183299%34, 344
   pad_or_crop.py40685%41, 44, 47, 50, 67, 74
   reshape.py139994%112, 308, 420–422, 443, 445, 452, 467
   slice_profiles.py49688%21, 37, 119–122, 155
   split_idx.py10280%43, 47
   summarize.py57689%40–41, 70–73, 81
   unit_conversion.py721579%34, 44, 51, 53, 62, 69, 71, 78, 80, 89, 100, 121, 123, 144, 146
TOTAL803355693% 

Tests Skipped Failures Errors Time
3018 0 💤 0 ❌ 0 🔥 2m 19s ⏱️

fzimmermann89 added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: 832ee30
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: d8b7108
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 4, 2025
ghstack-source-id: cf4fb96
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 11, 2025
ghstack-source-id: 5ecbdd5
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 11, 2025
ghstack-source-id: 02047df
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 11, 2025
ghstack-source-id: 1ba9226
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
fzimmermann89 added a commit that referenced this pull request Apr 11, 2025
ghstack-source-id: 4a64057
ghstack-comment-id: 2777263349
Pull-Request-resolved: #766
@fzimmermann89 fzimmermann89 changed the base branch from gh/fzimmermann89/80/head to main April 23, 2025 13:27
@fzimmermann89 fzimmermann89 force-pushed the gh/fzimmermann89/84/head branch from 9fade86 to 1b01c55 Compare April 23, 2025 13:33
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 23, 2025

📚 Documentation

📁 Download as zip
🔍 View online

@fzimmermann89 fzimmermann89 force-pushed the gh/fzimmermann89/84/head branch from 335f9cd to 967ea6a Compare April 26, 2025 21:41
@fzimmermann89 fzimmermann89 changed the title mrp h5 Add import/export of dataclasses to h5 Apr 27, 2025
@fzimmermann89 fzimmermann89 marked this pull request as ready for review April 27, 2025 15:24
@fzimmermann89 fzimmermann89 changed the title Add import/export of dataclasses to h5 Add import/export of dataclasses to hdf5-based mrp files Apr 27, 2025
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

mrge found 11 issues across 6 files. View them in mrge.io

Comment thread src/mrpro/data/Rotation.py
Comment thread src/mrpro/data/KHeader.py Outdated
Comment thread tests/data/test_kheader.py Outdated
Comment thread tests/data/test_kheader.py Outdated
Comment thread tests/data/test_kheader.py Outdated
Comment thread src/mrpro/data/Dataclass.py
Comment thread src/mrpro/data/Dataclass.py
Comment thread src/mrpro/data/Dataclass.py
Comment thread src/mrpro/data/Rotation.py
Comment thread src/mrpro/data/Rotation.py
@fzimmermann89 fzimmermann89 added the pre-commit.ci autofix run autofix in this PR label Apr 27, 2025
@pre-commit-ci pre-commit-ci Bot removed the pre-commit.ci autofix run autofix in this PR label Apr 27, 2025
@fzimmermann89
Copy link
Copy Markdown
Member Author

@ckolbPTB I would like to add this to one of the example notebooks. Then if we break something and the mrp import does not work anymore with the old mrp file, we notice and would have to update the file on zenodo.

unit test here would then just do kdata->mrp>kdata roundtrip.

Maybe we can have a short notebook about indexing, rearranging, moving to cuda, importing and exporting data?
without any reconstruction etc, just basics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant