I am trying to match MRI files with their volume files.
Background:
Link to files: https://wiki.cancerimagingarchive.net/pages/viewpage.action?pageId=68550661#68550661171ba531fc374829b21d3647e95f532c
The MRI files have the file path:
./manifest-1599764098812/Prostate-MRI-US-Biopsy/Prostate-MRI-US-Biopsy-0001/06-28-2009-NA-MRI PROSTATE W WO CONTRAST-51743/11.000000-t2spcrstaxial oblProstate-90221/1-01.dcm
The volume files have the file path with a long unique ID:
./STLs/Prostate-MRI-US-Biopsy-0001-ProstateSurface-seriesUID-1.3.6.1.4.1.14519.5.2.1.266717969984343981963002258381778490221.STL
I have a list (mriIdList.txt) which contains all of the ID files so that patient 1's first MRI is on the first line and so on. One patient can have multiple MRIs and each MRI has its own ID. Also I want to label the parent directory of the .dcm files since I will be processing the file folder. The numbers in the MRI file names are meaningless. Note the spacing in the file names.
Attempted Solution:
#!/bin/bash
find . -name "*{t2}*"
xargs -a ./mriIdList.txt -I {} -d'\n'
sed 's/.$1/.$1$2/'
This is my first script, so I'm sure it's messed up somewhere else, but my problem is that "find" goes through the directories in a computer-memory optimized way. I need to find MRI files going from left to right. (ie from Prostate-MRI-US-Biopsy-0001 to Prostate-MRI-US-Biopsy-0002). My general idea is to find directories labeled "t2", run through the ID list, and attach the ID to that directory. After that, I would use the ID to match up the MRIs with their volumes.
Example:
I created an example directory here: https://drive.google.com/drive/folders/17Gcl-IOjFzHKnIKEHVllLFDhcdR35E5c?usp=sharing
The first patient (Prostate-MRI-US-Biopsy-0001) has 1 MRI. The file path should changed to something like
/Prostate-MRI-US-Biopsy/Prostate-MRI-US-Biopsy-0001/06-28-2009-NA-MRI PROSTATE W WO CONTRAST-51743/11.000000-t2spcrstaxial oblProstate-90221_1.3.6.1.4.1.14519.5.2.1.266717969984343981963002258381778490221
The second patient has no MRIs, so he should be skipped.
The third patient has 3 MRIs. The first MRI should be
Prostate-MRI-US-Biopsy/Prostate-MRI-US-Biopsy-0003/05-01-2006-NA-MRI PROSTATE W WO CONTRAST-62671/3.000000-t2spcrstaxialp2-33258_1.3.6.1.4.1.14519.5.2.1.186749128823666050588710146976747922803
The second:
Prostate-MRI-US-Biopsy/Prostate-MRI-US-Biopsy-0003/09-21-2008-NA-MRI PROSTATE W WO CONTRAST-86577/9.000000-t2spcrstaxial oblProstate-31608_1.3.6.1.4.1.14519.5.2.1.134581986918909360753889591939462644248
The third:
Prostate-MRI-US-Biopsy/Prostate-MRI-US-Biopsy-0003/10-17-2009-NA-MRI PROSTATE W WO CONTRAST-68997/9.000000-t2spcrstaxial oblProstate-97825_1.3.6.1.4.1.14519.5.2.1.196285102861067055900322921931257124293
After that, I could pass in the MRI and STL files into a python script to extract image features since they have the same ID. It would be 1 matching MRI file and 1 STL file at a time. I'll take any and all advice on that operation too.
Any help or suggestions would be greatly appreciated.