====== Positron Emission Tomography ======
----
Online documentation - for instructors: [[https://positronemissiontomography.readthedocs.io/en/latest/index.html
]]
Online laboratory manual - for students: [[phylabs:lab_courses:phys-211-wiki-home:positron-emission-tomography:start]]
Github repository - setup related files :[[ https://github.com/UChicagoPhysicsLabs/PositronEmissionTomography
]]
Bill of Materials - for whomever wants to build a setup: [[https://docs.google.com/spreadsheets/d/1UGA9dp_g9l_pHDlyD9L5UesSFoDoISthVe1psVAu_JQ/]]
===== Useful Resources =====
==== Papers ====
[[https://doi.org/10.1119/1.1488636 | A simple experimental setup to demonstrate the basics of positron emission
tomography ]] - 2002 AJP paper that was the original basis of the experiment
[[https://doi.org/10.1063/1.2508724 | Use of Physical Models to Facilitate Transfer of Physics
Learning to Understand Positron Emission Tomography]] - 2006 PERC proceedings, more information is in the author's dissertation
[[https://doi.org/10.1063/1.3479888 | Teaching about the physics of medical imaging]] 2009 International Conference on Physics Educate (ICPE) proceedings. Only tangentially related.
[[https://doi.org/10.1088/1748-0221/19/04/P04001 | Design of low-cost digital pulse processing unit for gamma spectrometry]] - 2024 paper, uses an ARM microcontroller instead of an FPGA. Limited count rate, and not really suited for coincidence counting, but a good starting point for a student project.
[[https://doi.org/10.1016/j.nima.2016.11.031 | A flexible 32-channel time-to-digital converter implemented in a Xilinx Zynq-7000 field programmable gate array ]] 2017 paper on high-resolution timing measurements. The chips they use are 7020s instead of the Red Pitaya's 7010s, but the main difference is that the higher grade chips have more fabric elements (flip-flops, logic cells, etc) by around a factor of 3. Managed to achieve 5.8 ps time precision with 380 MHz measurable hit rate and 2.63 ns dead time.
[[https://doi.org/10.1109/TIM.2019.2938436 | Recent Developments and Challenges in FPGA-Based Time-to-Digital Converters ]] - 2019 paper covering different methods of high-precision interval measurement. Good overview paper for finding more information.
[[https://stax.strath.ac.uk/concern/theses/1z40kt39g | Development of low-cost field-programmable gate array based time-to-digital converters for time-resolved measurements]]
===== Websites =====
==== Tomography ====
[[https://www.slaney.org/pct/pct-toc.html | Principles of Computerized Tomographic Imaging]] - Online book by Avinash C. Kak and Malcolm Slaney
==== FPGA ====
As a general note, there are a few common families of FPGA devices which have differing development tools.
* Xilinx (owned by AMD) are associated with Vivado as a development tool
* Altera (owned by IBM) are associated with Quartus
* Lattice Semiconductor are associated with Radiant (?)
* Microsemi chips are associated with Libero
[[https://docs.amd.com/v/u/en-US/dh0050-zynq-7000-design-overview-hub | Zynq-7000 SoC Design Overview Design Hub]] - Has relevant datasheets & pinouts for the chip at the heart of the Red Pitaya. The specific chip is the ''xc7z010clg400-1'' for the 125-14 versions of the devices. The second generation **should** be the same.
[[https://www.zynqbook.com/ ]] - Scottish Engineering group's book on the Zynq chip.
[[https://digilent.com/blog/fpga-for-beginners-glossary-and-setup/ | FPGA for beginners Glossary]] - From Digilent, but the language is still relevant
=== Red Pitaya ===
[[https://lniv.fe.uni-lj.si/redpitaya/index.html | Laboratory for Integrated Circuit Design: Red Pitaya Projects ]] - Slovenian website with a few useful examples.
[[https://github.com/pavel-demin/red-pitaya-notes/]] - Pavel Demin's Github, more useful than the actual official documentation.
[[https://antonpotocnik.com/?p=487360 | Anton Potočnik's Tutorials ]] - This is the first of five tutorials on creating some basic projects on the Red Pitaya. Incredibly useful place for a novice to start.
[[https://github.com/XavierAudier/minimal_redpitaya/|]] - A Github repository containing a minimally working project for starting with the Red Pitaya.
[[https://github.com/marceluda/rp_lock-in_pid ]] - Lock-in amplifier and PID code for a Red Pitaya. Author also has a lock-in amplifier and scope project.
[[https://redpitaya.readthedocs.io/en/latest/intro.html| Official Documentation ]] - Can be tricky to navigate, but does ultimately have most of the information you'd need to work with the devices. Of particular use are the pages for:
* [[https://redpitaya.readthedocs.io/en/latest/developerGuide/hardware/GEN1/125-14/top.html | Hardware information]]
* [[https://downloads.redpitaya.com/doc//Red_Pitaya_Schematics_v1.0.1.pdf | Device schematic ]]
* [[https://redpitaya-knowledge-base.readthedocs.io/en/latest/learn_fpga/3_vivado_env/tutorfpga2.html | FPGA coding setup ]]
== Red Pitaya Papers ==
[[https://doi.org/10.1063/1.5080345 | Compact embedded device for lock-in measurements and experiment active control]] - 2019 paper on other uses for the Red Pitaya in the lab.
[[https://doi.org/10.1109/TIM.2022.3165291 | FPGA-Based High-Speed Optical Fiber Sensor Based on Multitone-Mixing Interferometry ]] - Optics with the Red Pitaya
[[https://doi.org/10.1063/5.0157330 | A many-channel FPGA control system]] - Yet more applications
[[https://doi.org/10.3390/agronomy13071778 | Design of a Tomato Sorting Device Based on the Multisine-FSR Composite Measurement ]] - Using a Red Pitaya to measure the impedance of tomatoes to characterize how ripe they are. I love that this exists.
== making .bif files ==
As of the OS 2.0 update, the way that files are uploaded to the Red Pitaya has changed. You no longer upload the raw bitstream but instead make a bootable bitstream ''.bif'' file. The official solution only seems to work straight from the .tcl command line, so to streamline the approach I came up with the following solution:
make a file called ''rp_post.tcl'' with the following contents:
set biffile [open "system_wrapper.bif" w+]
put $biffile "all:{ system_wrapper.bit }"
close $biffile
exec bootgen -image system_wrapper.bif -arch zynq -process_bitstream bin -o system_wrapper.bit.bin -w
In Vivado, navigate to the project ''Settings'' => ''Bitstream'' and set the file for the ''tcl.post'' option.
----
==== Other Info ====
To make your machine a trusted client so you don't need to enter a password to login:
- Grab https://gitforwindows.org/
- Run it, use the command ''ssh-keygen'' to make a key pair
- This is assuming we're calling it ''id_rsa''
- copy the public key with something like ''ssh-copy-id -f -i id_rsa.pub root@red_pitaya_address''
- log in via ''ssh -i id_rsa root@red_pitaya_address''
- If the key isn't working, chmod 600 the ''.ssh'' directory and ''.ssh/authorized_keys'' file on the Red Pitaya side
=== Synchronizing files ===
To synchronize files to your local machine, some flavor of shell script works well. For windows, a powershell file along the lines of
scp -i "path_to_ssh_key" root@rp-XXXXXX.local/home/jupter/*.csv c:/your_path_here
where the ''path_to_ssh_key'' is pointed to your local private key, ''root@rp-XXXXXX'' should have the Xs replaced with the last 6 characters of the device's MAC address, and ''your_path_here'' is pointed wherever you want things stored locally.
If you save a version of that command as a ''.ps1'' file, you can then use Windows Task Scheduler to run it periodically. I use a 1 hour interval but do as you please.
=== Working with Vivado ===
* There is a maximum character length for file paths, and projects tend to have a rather deep nested structure. Shorter filenames can help avoid obscure errors
* Unlike modern operating systems, TCL does not handle whitespace in filenames gracefully. Just don't do it.