Share password-protected MRI MPRAGE images via Nextcloud. Uploads NIFTI files to Nextcloud zipped with a random password. You send the link to the NIFTI via mail and the password via a secure second channel e.g. WhatsApp or Signal.
-
clone this repository to your local machine
-
install the following via pip:
pip install dicom2nifti wordfreq tqdm pyminizip
or usepip install -r requirements.txt
then enter your credentials into
credentials.json
PS: Best practice is to create an API app password in the Nextcloud settings under "security". Don't store your actual user password in plain text on disc, only the app password.
{"username": "username", # user name for nextcloud
"password": "password", # password for the user
"remote_path": "MRI-share", # folder on nextcloud in which the files are uploaded. Needs to exist already.
"expiration_days": 21, # delete share after this time
"include_mricron": true, # include a program to view NIFTI files (Windows only)
"nextcloud_baseurl": "https://cloud.server.de" # server URL
The script expects the the DICOMS to be in subfolders of a main folder, with each folder being named after the participant in question.
├───mri_images
│ ├───subj1
│ │ mprage1.ima
│ │ mprage2.ima
│ │ mprage3.ima
│ │ ....
│ ├───subj2
│ │ ...
│ └───subj3
│ │ .....
- run script via
python share_with_password.py
and select the folder that contains the DICOM folders (i.e. the folder above the actual DICOM images, not the folder containing the DICOM images themselves) - The script will create random passwords and upload the files to nextcloud
- A
share-list.xlsx
will be created containing all the links and passwords. - If you need to re-share a file, simply delete the row of the participant from the excel list
- Send the link to the participant via email. Send the password via a separate, secure channel (i.e. WhatsApp, Signal, iMessage or snail mail).
There is a sample mail available here: mail template