Skip to content

Conversation

@schuenke
Copy link
Collaborator

@schuenke schuenke commented Jan 8, 2025

This PR is needed to update the new default branch (master) to the old one (dev)

tblazey and others added 30 commits March 24, 2023 13:56
Fix README.md: latest make_sinc_pulse dont return gradient by default
Fix unit issue.
…ct test reports (e.g. wrong slew rates!) and incorrect k-space trajectory calculation. (#125)

Checked test reports for gre, tse, gre_radial, ute, and epi_se_rs to be identical with MATLAB.

Additionally made some minor changes that avoid some warnings (bad conditioning in polynomial fit and division by zero).

Co-authored-by: Frank Zijlstra <[email protected]>
…114)

* Hacky fix for waveforms_and_times rf append floating point issue.
* Use rf raster instead of eps
Sequence.waveforms_and_times:
- Fixed missing implementation for recompressing trapezoids from arbitrary gradients. Now proceeds without recompressing and added a TODO to implement the MATLAB code.
- Fixed issue where rounding errors could create non-monotonically increasing times. Also moved the non-monotonicity check outside the loop.

make_trapezoid:
- Fixed bug that would give an 'requested area is too large' error when explicitly specifiying a triangular gradient with duration, rise_time, and area.
- Fixed check for area == 0, while an unspecified area would be None
- Actually fixed the non-monotonic time problem
- Two small fixes in sequence plot() that cut off the start of the sequence when time_range is specified, and coloured labels wrongly.
Changes `shape_pieces` to Python lists, allowing them to be concatenated without a loop. Cleaner code, and slightly faster too.
…nd `rotate` (#132)

* Several bug fixes in Sequence, add_gradients, make_trapezoid, and `rotate`:

- Bypass code for `restoreAdditionalShapeSamples` did not include `grad.first` and `grad.last`
- `make_arbitrary_grad` was not available as `pp.make_arbitrary_grad`
- `add_gradients`' detection of arbitrary gradients was incorrect for Python's 0-based indexing
- `add_gradients` handling of non-unique times was broken
- `make_trapezoid` incorrectly checked and reported the minimum duration for gradients specifying area and duration (also fixed in local upstream MATLAB pulseq)
- `rotate` did not have a system parameter
- `rotate` used the incorrect channel for gradient on the second rotation axis
- Small change in `add_gradients` to accept a single gradient (i.e. for cases where a variable number of gradients are added), which also allowed a minor cleanup in `rotate`

* Fixed `test_report` when gradient waveforms are not of equal size
This is a direct translation of the MATLAB Pulseq calcPNS function to python, renamed to calculate_pns. This includes a partial translation of the MATLAB safe_pns_prediction repository (https://github.com/filip-szczepankiewicz/safe_pns_prediction), put into utils/safe_pns_prediction.py. To test the functionality, this adds the pnsTest sequence "example" from MATLAB Pulseq.
- np.floor -> math.floor
- np.ceil -> math.ceil
- np.abs -> abs (could also be done for array operations with no performance hit)
- np.round -> round
- np.max -> max

Performance improvements range from 10x - 50x
… `test_report`

- Changed handling of `next_free_ID` to properly work with used-specified `key_id`
…epeatedly accessed (i.e. `calculate_kspace`, `test_report`, `calculate_pns`, etc.)

- Added `use_block_cache` option to sequence to disable the caching to save memory (defaults to True)
- Avoid unnecessary deepcopy's
- Improved checks for trapezoid timing (pure-Python instead of np.unique)
- Avoid unnecessary computations for adding (extended) trapezoids
dependabot bot and others added 17 commits September 3, 2024 22:50
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.1.7.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](actions/download-artifact@v3...v4.1.7)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <[email protected]>
…dot-github/workflows/actions/download-artifact-4.1.7
* Removed trailing whitespace in a number of files

* Corrected `system == None` checks to `system is None` and fixed `system` type hints

* Added warnings where RF and ADC delays were silently increased to the dead time

* Fixup: system type hint

* Removed silent adjustment of ADC delay to ADC dead time
(This should be caught by `make_adc`. If we get here, the user really wants to adjust the delay and just accept it and let `check_timing` report it)

* Reworked `check_timing` to provide a structured error report
- Added unit test for `check_timing`
- The default signature of `seq.check_timing` remains the same, but can pretty-print the report with `print_errors=True`
- `seq.write` now checks sequence timing by default
- 'TotalDuration' calculation moved from `check_timing` to `seq.write`
- Check whether gradients in the last block ramp down to zero removed from `check_timing`

* Added optional tracing of where blocks/events were created
- Can be enabled/disabled with `pp.enable_trace(limit)` and `pp.disable_trace()`
- Added tracing to all blocks and all RF/ADC/gradient events
- Added printing of the trace to `check_timing` when it is available

* Fixed `check_timing` to not assume `rf_raster_time == adc_raster_time`

* Updated expected output for `test_sequence` because it did not include `TotalDuration` in the sequence definitions

* Fixed continuity checks for arbitrary gradients
- `Sequence.write` now checks whether the last block ramps down to 0
- Fixed gradient continuity checks in `set_block`
  - Now handles arbitrary block orders properly
  - Now properly checks the last value of the previous block
  - Added gradient checks for blocks without gradients
  - Sequence object now remains valid after gradient errors
- Added unit tests for gradient continuity in `test_block`

* fix None checks
fix some type hints
some cleanup

* refactor timing error report in test_report

---------

Co-authored-by: Patrick Schuenke <[email protected]>
* add pre-commit workflow

* add pre-commit config including ruff, typos

* ruff rules to pyproject.toml

* reformat / refactor code to pass checks
* Add `Sequence.install` functionality
- The Matlab pulseq implementation for Siemens scanners is included
- Custom scanner targets can be added using `pypulseq.Sequence.install.register_scanner`

* reformat code to pass pre-commit checks

---------

Co-authored-by: Patrick Schuenke <[email protected]>
* * fix: exceed of max slew rate for gradient event if make_trapezoid() is called.

* [pre-commit] auto fixes from pre-commit hooks

* Update make_trapezoid.py to add slew rate check for the ramp down as well

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: FrankZijlstra <[email protected]>
* * fix: exceed of max slew rate for gradient event if make_trapezoid() is called.

* - check that waveform does not exceed max_slew and max_grad

* [pre-commit] auto fixes from pre-commit hooks

* Update make_extended_trapezoid.py to avoid unnecessary conversion to arbitrary just for the slew rate check

* [pre-commit] auto fixes from pre-commit hooks

* Changed slew rate and max_grad checks from >= to > with `eps` tolerance

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: FrankZijlstra <[email protected]>
* change to src layout and adjust configs

* introduce conftest.py in tests

* remove old empty SAR folder from utils

* fix include of QGlobal.mat in distribution
updates:
- [github.com/pre-commit/pre-commit-hooks: v4.6.0 → v5.0.0](pre-commit/pre-commit-hooks@v4.6.0...v5.0.0)
- [github.com/astral-sh/ruff-pre-commit: v0.6.9 → v0.8.6](astral-sh/ruff-pre-commit@v0.6.9...v0.8.6)
- [github.com/crate-ci/typos: v1.25.0 → dictgen-v0.3.1](crate-ci/typos@v1.25.0...dictgen-v0.3.1)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
@schuenke schuenke marked this pull request as ready for review January 8, 2025 15:20
@btasdelen
Copy link
Collaborator

Should we do this after merging #212, #220, #227 ?

@schuenke
Copy link
Collaborator Author

schuenke commented Jan 9, 2025

IMO we should have done it before switching the branches, but at least we should do it now as fast as possible.

If ppl install from GitHub, they currently get 2 years old code. This should be fixed asap.

@schuenke
Copy link
Collaborator Author

schuenke commented Jan 9, 2025

@FrankZijlstra could you approve this as well? Need 2 approving reviews to merge into master now.
There is no change compared to current dev branch. So no code to review.

@schuenke schuenke merged commit 340620f into master Jan 10, 2025
13 checks passed
@schuenke schuenke mentioned this pull request Mar 21, 2025
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.