simnibs_analyze._citations

Dependency citations for simnibs-analyze.

Called once at pipeline startup (run.py) to print BibTeX references for all tools used, so users can cite them properly.

Uses duecredit when available; falls back to a plain-text summary.

  1"""
  2Dependency citations for simnibs-analyze.
  3
  4Called once at pipeline startup (run.py) to print BibTeX references
  5for all tools used, so users can cite them properly.
  6
  7Uses duecredit when available; falls back to a plain-text summary.
  8"""
  9
 10from __future__ import annotations
 11
 12_CITATIONS = [
 13    {
 14        "tool": "SimNIBS",
 15        "doi": "10.1016/j.neuroimage.2019.116183",
 16        "ref": (
 17            "Thielscher A, Antunes A, Saturnino GB (2015). "
 18            "Field modeling for transcranial magnetic stimulation: a useful tool "
 19            "to understand the physiological effects of TMS? "
 20            "IEEE EMBC 2015. doi:10.1109/EMBC.2015.7318340"
 21        ),
 22    },
 23    {
 24        "tool": "ANTsPy",
 25        "doi": "10.5281/zenodo.2629946",
 26        "ref": (
 27            "Avants BB et al. (2009). "
 28            "A reproducible evaluation of ANTs similarity metric performance in "
 29            "brain image registration. NeuroImage 54(3):2033-2044. "
 30            "doi:10.1016/j.neuroimage.2010.09.025"
 31        ),
 32    },
 33    {
 34        "tool": "nilearn",
 35        "doi": "10.3389/fninf.2014.00014",
 36        "ref": (
 37            "Abraham A et al. (2014). "
 38            "Machine learning for neuroimaging with scikit-learn. "
 39            "Frontiers in Neuroinformatics 8:14. doi:10.3389/fninf.2014.00014"
 40        ),
 41    },
 42    {
 43        "tool": "nibabel",
 44        "doi": "10.5281/zenodo.3269256",
 45        "ref": (
 46            "Brett M et al. (2024). nipy/nibabel. Zenodo. " "doi:10.5281/zenodo.3269256"
 47        ),
 48    },
 49    {
 50        "tool": "NumPy",
 51        "doi": "10.1038/s41586-020-2649-2",
 52        "ref": (
 53            "Harris CR et al. (2020). "
 54            "Array programming with NumPy. Nature 585:357-362. "
 55            "doi:10.1038/s41586-020-2649-2"
 56        ),
 57    },
 58    {
 59        "tool": "pandas",
 60        "doi": "10.25080/Majora-92bf1922-00a",
 61        "ref": (
 62            "McKinney W (2010). "
 63            "Data Structures for Statistical Computing in Python. "
 64            "Proceedings of the 9th Python in Science Conference, 51-56. "
 65            "doi:10.25080/Majora-92bf1922-00a"
 66        ),
 67    },
 68    {
 69        "tool": "matplotlib",
 70        "doi": "10.1109/MCSE.2007.55",
 71        "ref": (
 72            "Hunter JD (2007). "
 73            "Matplotlib: A 2D graphics environment. "
 74            "Computing in Science & Engineering 9(3):90-95. "
 75            "doi:10.1109/MCSE.2007.55"
 76        ),
 77    },
 78    {
 79        "tool": "PyVista",
 80        "doi": "10.21105/joss.01450",
 81        "ref": (
 82            "Sullivan CB, Kaszynski A (2019). "
 83            "PyVista: 3D plotting and mesh analysis through a streamlined "
 84            "interface for the Visualization Toolkit (VTK). "
 85            "Journal of Open Source Software 4(37):1450. doi:10.21105/joss.01450"
 86        ),
 87    },
 88]
 89
 90
 91def print_citations() -> None:
 92    """Print dependency citation notices to stdout."""
 93    # Try duecredit first
 94    try:
 95        from duecredit import due, Doi, BibTeX  # noqa: F401
 96
 97        for entry in _CITATIONS:
 98            due.cite(
 99                Doi(entry["doi"]),
100                description=entry["tool"],
101                path="simnibs_analyze",
102                cite_module=True,
103            )
104        # duecredit handles printing at process exit automatically
105        return
106    except ImportError:
107        pass
108
109    # Fallback: plain text
110    separator = "-" * 60
111    print(separator)
112    print("simnibs-analyze uses the following tools — please cite them:")
113    print(separator)
114    for entry in _CITATIONS:
115        print(f"\n[{entry['tool']}]\n  {entry['ref']}")
116    print(f"\n{separator}")
117    print("Install duecredit for BibTeX output:  pip install duecredit")
118    print(separator)