Logo Pulse Sequence Design

Pulse Sequence Design

Cộng đồng
KeWang0622
pulse-sequence-design

Read before designing, exporting or simulating an MRI acquisition: pulse sequences, RF and gradient waveforms, k-space trajectories (Cartesian, radial, spiral, EPI), Pulseq/PyPulseq files and Bloch simulation of the export. Prevents silent errors in realized TE/TR/TI and echo spacing, sampling and coverage requirements, spoiling and receive phase, gradient continuity, slice selection, steady state and delivered simulations that differ from a fresh simulation of the file. Ships tested builders, an exported-sequence checker, a KomaMRI replay check and an end-to-end example.

Tổng quan

Nhà phát hànhKeWang0622
Kho mãMRFoundry
Tên kỹ năngpulse-sequence-design
Sao
31
Bản fork
0
Tệp đi kèm
9
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 9 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được KeWang0622 công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Pulse Sequence Design trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/KeWang0622/MRFoundry/tree/main/skills/pulse-sequence-design
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/KeWang0622/MRFoundry.git /tmp/MRFoundry
mkdir -p .claude/skills
cp -r /tmp/MRFoundry/skills/pulse-sequence-design .claude/skills/pulse-sequence-design
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Pulse Sequence Design trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Pulse Sequence Design ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Pulse Sequence Design không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

MRFoundry: Pulse Sequence and Trajectory Design

Prototype vendor-neutrally with PyPulseq. Treat the build script as a claim and the exported .seq as the evidence: measure the export, simulate the export, reconstruct from the simulation of the export.

Fast path (sequence -> Bloch simulation -> reconstruction -> report)

  1. Simulator first (it takes minutes): pip install pypulseq sigpy matplotlib komamripy, then start python .agents/skills/pulse-sequence-design/scripts/test_seqlib.py > warmup.log 2>&1 & (installs Julia + KomaMRI; keep logs in the workspace, /tmp may be read-only). If no Julia appears within about 3 minutes (empty log, a juliapkg lock wait, an install error), stop it and run sh .agents/skills/pulse-sequence-design/scripts/setup_koma_julia.sh > koma.log 2>&1 & (Julia 1.10 + KomaMRICore in ./koma_julia), then simulate_with_koma(..., backend='julia') with the paths it prints. Both backends give the same signal. Deliver KomaMRI output only: MRzero, EPG, homemade Bloch code and ideal-signal formulas have not matched KomaMRI replays of the same file (scale, sign and timing conventions differ).
  2. Copy scripts/example_pipeline.py (build, read back, waveform figure, simulation of the exported file, archive with hashes, replay check, standalone reconstruction, orientation check, report) and swap in a family builder: spoiled GRE in scripts/test_seqlib.py; inversion-recovery GRE, balanced SSFP, spin echo, CPMG and EPI in scripts/test_check_exported_seq.py. Helpers (mrfoundry_seqlib.py --api): make_system, slice_selective_excitation (center_shift), centered_readout and add_epi_readout (oversample, extra, adc_shift), split_interval, fill_delay, RFSpoiler, spoiler_area, kspace_grid, simulate_with_koma, replay_check, plot_waveforms.
  3. Run the checker with EVERY requested parameter until all lines PASS and NOT CHECKED is empty; verify each VERIFY SEPARATELY item yourself or by simulating the exported file (--help lists the flags; do not read the source): python .agents/skills/pulse-sequence-design/scripts/check_exported_seq.py sequence.seq --te ... --matrix NX NY --fov F ...
  4. Simulate the exact file you deliver and save the samples as returned (KomaMRI gives sum rho exp(-2 pi i k.r) with pypulseq's k: never conjugate, rescale or reorder them). Before finishing, run replay_check(seq, delivered, x, y, z, rho, T1, T2): it re-simulates the delivered file from scratch and must report a difference below 1 %.
  5. Grid samples with kspace_grid (exported k; drop_off_grid=True for oversampled lines), fit maps with mri-reconstruction/scripts/qmri_fit.py, check orientation on a simulated asymmetric object, and report values measured from the export and endpoint values from the delivered image, applying the task's region definition as written in every image dimension. If a region rule can be read in more than one way, compute each reading on the delivered image, report the plainest and note the others. One script per stage, in the workspace root; keep printed output short.

Rules the checker enforces

TopicRuleFlags
TimingTE = excitation centre -> k = 0 sample; TR = excitation-centre spacing; meet each within the task tolerance. The 10 us block raster can leave 5 us: put the remainder in the RF delay (split_interval + center_shift) or in a single readout's ADC (adc_shift); never report a raster-rounded value as meeting a tighter tolerance. RF and ADC keep their dead and ringdown times inside each block--te --tr --ti --time-tol (default 1 us), --rf-dead-time --rf-ringdown-time --adc-dead-time
Sampling, exact positionseach sample index has a required k position: n samples, oversample=1--matrix NX NY [NZ] --fov F
Sampling, coveragean interval of k must be covered with a bounded sample spacing: oversample=2, extra>=1, so samples pass both ends and the step stays below the bound. Exactly n samples sit ON the ends with the step AT the bound, and the 6-digit export rounding breaks that about half the time--kx-cover LO HI --max-gap G
Acquired linesan ADC in a dummy or preparation repetition counts as an extra acquisition, so leave it out; every line is acquired the stated number of times; 3D: each cycle encodes its own partition--line-repeats R --n-adc N
GradientsPulseq amplitudes are Hz/m (mT/m x 42.576e3), areas 1/m (cycles/m); arbitrary gradients (spirals) start and end at 0 with explicit first=0, last=0 (or the neighbouring block's value), otherwise the extrapolated end values jumpcontinuity always checked; --max-grad --max-slew
Slice selectionsinc/SLR pulse WITH its slice-select gradient, then the rephaser; hard pulses are non-selective--slice-thickness
Spoiled GREquadratic RF spoiling; each ADC takes its excitation's phase; spoiler after the last ADC; multi-echo monopolar needs flyback--rf-spoil 117 --min-spoil-cycles 2 --monopolar
Inversion recovery, MP-RAGETI = inversion centre -> excitation centre (MP-RAGE: the excitation of the central k-space line); the same timing in every cycle, dummies too; spoil after the inversion; simulate one column of spins through the slab to verify a tissue null and that the signal no longer changes from one acquired cycle to the next (point isochromats can keep coherent echoes under a constant spoiler: vary the spoiler moment or the RF increment if the null fails); fit a + b exp(-TI/T1) or a dictionary of the exact timing--ti ... --tr TRAIN_TR CYCLE_GAP --min-inversion-spoil-cycles 2
Spin echo, TSE, CPMGrefocusing centre at TE/2 (ESP/2); CPMG phase = excitation +/- 90 deg; rewind each phase encode before the next refocusing pulse; crusher moments equal on both sides and inside the range with margin; reach steady state before acquiring (dummy shots without ADC; confirm by simulating one column of spins)--te --cpmg --crusher-range LOW HIGH
UTE half-pulsetwo half-pulse acquisitions per spoke with opposite slice-gradient polarity, added as complex signals. Play each half pulse on the gradient plateau and set center= to its last sample, so the slice gradient is at full strength at the RF centre (a pulse that continues into the ramp-down peaks where the gradient is nearly 0); one lobe then ramps down and cancels the slice-gradient area that follows the RF centre, so the readout starts with kz = 0. The ADC delay respects the ADC dead time and the readout starts at k = 0 with its first sample; simulate single spins along z through both acquisitions to measure the summed slice response--n-adc; gradient at each RF centre always checked
Diffusion (SE-EPI)b-matrix from the exported waveforms using the effective gradient (sign inverted after each refocusing pulse); the same crushers around the refocusing pulse in every volume (b = 0 too) and a refocusing slab wider than the excited slice when spins extend beyond it; dummy repetitions before the first acquired volume unless TR >> T1. Point isochromats do not diffuse: a simulation without diffusion weighting must give the same signal in every volume (check it; differences bias the fit)--te --crusher-range
Balanced SSFPzero net area per TR; TE = TR/2; 0/180 phase cycling with matching ADC phase; catalyze or use dummies--balanced --rf-phase-cycle 180 --te-half-tr
EPITE to the kx = ky = 0 sample of the train; constant line period; odd lines traverse the same grid backwards; no ramp sampling unless allowed; with ramp sampling the first and last samples must still pass the coverage ends--epi --echo-spacing ES

Margins. Design 2-5 % inside every limit and range (raster rounding moves areas, timing and slew; the checker WARNs within 2 %). Report safety and timing values measured from the export: --safety with --b1rms-max --b1peak-max --grms-max --pns-rheobase --pns-chronaxie --pns-max and --json.

Before you finish

python .agents/skills/mri-research-workflow/scripts/finish_check.py --require <every deliverable name> \
    --rerun "python <entrypoint> <documented arguments with {inputs} and {out}>" --inputs <input folder>

Every listed output, build and simulation scripts and their imported helpers included, goes directly in the folder the task names (workspace root if none), never in scripts/; name the actual script files in --require. If the simulation could not run, say so plainly; never fabricate simulated or reconstructed outputs.

More (open only when needed)

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Pulse Sequence Design làm được gì?

Read before designing, exporting or simulating an MRI acquisition: pulse sequences, RF and gradient waveforms, k-space trajectories (Cartesian, radial, spiral, EPI), Pulseq/PyPulseq files and Bloch simulation of the export. Prevents silent errors in realized TE/TR/TI and echo spacing, sampling and coverage requirements, spoiling and receive phase, gradient continuity, slice selection, steady state and delivered simulations that differ from a fresh simulation of the file. Ships tested builders, an exported-sequence checker, a KomaMRI replay check and an end-to-end example.

Vì sao nên dùng Pulse Sequence Design trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Pulse Sequence Design là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Pulse Sequence Design trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/KeWang0622/MRFoundry/tree/main/skills/pulse-sequence-design. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Pulse Sequence Design?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Pulse Sequence Design với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Pulse Sequence Design với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Pulse Sequence Design có miễn phí không?

Có. Kỹ năng này được KeWang0622 phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇