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

Fix SAR calculation #223. #249

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

h3lg3
Copy link
Contributor

@h3lg3 h3lg3 commented Feb 12, 2025

Aligns SAR array with time array.
Closes #223

    for block_counter in block_events:
        block = seq.get_block(block_counter)
        block_dur = calc_duration(block)
        t[block_counter - 1] = t_prev + block_dur
        t_prev = t[block_counter - 1]
        if hasattr(block, 'rf') and block.rf is not None:  # has rf event
            rf = block.rf
            signal = rf.signal
            # This rf could be parallel transmit as well
            SAR_wbg[block_counter - 1] = _calc_SAR(Qtmf, signal) # added -1 here
            SAR_hg[block_counter - 1] = _calc_SAR(Qhmf, signal) # added -1 here

Copy link

github-actions bot commented Feb 12, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
/home/runner/.local/lib/python3.12/site-packages/pypulseq
   add_gradients.py1235159%44, 52, 58, 61, 75–86, 92, 120–123, 130–131, 150, 157, 162–241
   add_ramps.py36360%1–89
   align.py35489%41, 45, 69, 73
   calc_duration.py25196%37
   calc_ramp.py2182142%45–353
   calc_rf_bandwidth.py272026%37–59, 63–67
   check_timing.py872769%72, 76, 99, 192, 199, 209–253
   compress_shape.py30197%28
   convert.py40880%42, 48, 66, 72–73, 82, 88–89
   event_lib.py961485%6–9, 48–51, 70–71, 205–210
   make_adc.py921386%63, 72–76, 79, 128, 131, 135, 141, 145, 184, 186, 188, 196
   make_adiabatic_pulse.py1293970%196–200, 217–221, 229–230, 253, 259, 328–347, 451–460, 498–506
   make_arbitrary_grad.py363017%66–104
   make_arbitrary_rf.py665517%83–160
   make_block_pulse.py46393%112–116, 119
   make_delay.py9189%27
   make_digital_output_pulse.py16288%39, 47
   make_extended_trapezoid.py561475%67, 70, 76, 82, 85, 88, 91, 94, 104–105, 116, 134, 136, 139
   make_extended_trapezoid_area.py92397%48, 221, 224
   make_gauss_pulse.py692071%127–131, 134–158, 165, 168
   make_label.py19384%36, 41, 43
   make_sigpy_pulse.py1203174%12–13, 94, 97, 101, 136, 139–143, 147, 150–151, 154–155, 170, 182, 187, 199, 202, 227–237, 251, 254, 284–294
   make_sinc_pulse.py681085%94, 100, 127–131, 135, 138–139, 142–143, 165
   make_trapezoid.py111794%177, 190, 196, 214, 232, 237, 255
   make_trigger.py16288%44, 52
   opts.py66986%78, 83, 102, 142, 166–170
   points_to_waveform.py9722%23–38
   rotate.py691480%15, 55, 66–69, 85–90, 112, 119–120
   scale_grad.py14471%28–30, 33
   sigpy_pulse_opts.py26773%34–41
   split_gradient.py393121%46–103
   split_gradient_at.py702761%63–90, 110, 114, 118–120, 154–156
   traj_to_grad.py13931%26–40
/home/runner/.local/lib/python3.12/site-packages/pypulseq/SAR
   SAR_calc.py1139813%33–40, 55–62, 89–108, 129–132, 168–212, 242–246, 264–306
/home/runner/.local/lib/python3.12/site-packages/pypulseq/Sequence
   block.py3683291%59, 62, 70, 76, 91, 99, 105, 116, 119, 122, 130, 135, 144, 196, 245, 249, 265, 305–308, 337–338, 404, 410, 430, 499, 535, 541, 568, 606, 640
   calc_grad_spectrum.py81766%68–190
   calc_pns.py403122%45–96
   ext_test_report.py1401192%23, 58, 61, 135, 227–233
   install.py754244%31, 52, 69, 71, 112–131, 148, 181–184, 200–212, 254–278
   parula.py4250%19–86
   read_seq.py3157177%42–43, 90, 93, 105, 110, 116, 123, 132, 141, 146, 149, 157–159, 192, 197, 205–254, 284–288, 299–303, 329–346, 409, 412, 447, 455, 529, 571–575
   sequence.py72321770%11–14, 101–111, 132–145, 183, 248–251, 292, 319, 336, 384, 412, 439–444, 481, 497, 588, 610, 651–654, 708, 740, 751–752, 758, 769, 775, 777, 785, 818–826, 847–869, 912, 914, 917, 943–944, 947–950, 986–996, 1034–1035, 1071–1072, 1098, 1104, 1107, 1144, 1265–1278, 1301, 1329, 1351–1353, 1374, 1405, 1416–1429, 1441–1452, 1498–1499, 1508–1526, 1550, 1580–1588, 1620–1730, 1759, 1773–1783, 1795
   write_seq.py172895%41, 65, 68–75
/home/runner/.local/lib/python3.12/site-packages/pypulseq/utils
   cumsum.py14193%17
   safe_pns_prediction.py12611310%50–87, 102–189, 197–214, 222, 244–250, 279–286, 310–336, 344–383, 396–411, 415
   tracing.py16662%33–34, 42, 54–55, 75
/home/runner/.local/lib/python3.12/site-packages/pypulseq/utils/siemens
   asc_to_hw.py58539%21–28, 48–106
   readasc.py48456%25–100
TOTAL4363152365% 

Tests Skipped Failures Errors Time
1185 18 💤 0 ❌ 0 🔥 2m 48s ⏱️

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.

SAR calculation depends on the duration of the event following the RF event
1 participant