def scan_link(self, instance: NIfTI) -> str: try: scan = Scan.objects.get(_nifti=instance) except Scan.DoesNotExist: pass else: return Html.admin_link("Scan", scan.id)
def nifti(self, instance: Scan) -> str: if instance._nifti: model_name = instance.nifti.__class__.__name__ pk = instance.nifti.id link = Html.admin_link(model_name, pk) url = reverse("mri:nifti_to_zip", args=(instance.nifti.id, )) button = DOWNLOAD_BUTTON.format(url=url, file_format="nifti", text="Download") return mark_safe(f"{link}{button}")
def dicom_link(self, instance: Scan) -> str: if instance.dicom: model_name = instance.dicom.__class__.__name__ pk = instance.dicom.id link = Html.admin_link(model_name, pk) url = reverse("dicom:to_zip", args=(instance.dicom.id, )) button = DOWNLOAD_BUTTON.format(url=url, file_format="dicom", text="Download") return mark_safe(f"{link}{button}")
def measurement_link(self, instance: Session) -> str: if instance.measurement: model_name = instance.measurement.__class__.__name__ pk = instance.measurement.id text = instance.measurement.title return Html.admin_link(model_name, pk, text)
def subject_link(self, instance: Session) -> str: if instance.subject: model_name = instance.subject.__class__.__name__ pk = instance.subject.id text = instance.subject.id_number return Html.admin_link(model_name, pk, text)
def subject_link(self, instance: Scan) -> str: model_name = instance.session.subject.__class__.__name__ pk = instance.session.subject.id return Html.admin_link(model_name, pk)
def analysis_version_link(self, instance: Run) -> str: model_name = instance.analysis_version.__class__.__name__ pk = instance.analysis_version.id text = str(instance.analysis_version) return Html.admin_link(model_name, pk, text)
def run_link(self, instance: Run) -> str: model_name = instance.__class__.__name__ pk = instance.id return Html.admin_link(model_name, pk)