Good to hear all this time spent coding up the DICOM import hasn't been wasted
You'll find all the DICOM handling code in
image.cpp file is probably most relevant to you here. Bear in mind that DICOM handling on MRtrix differs substantially from most other utilities I'm aware of, in that it only parses the bits we're interested in - we don't form the full tree of DICOM tags like other libraries might. See this recent post for some related information.
One way to kind of do what you're asking in your first question is a trick I use in scripts when I already know what answers I need to provide to select the right series: feed your ready-made answers through
stdin. For example:
echo "1 5" | mrinfo DICOM/
would select study/patient 1, then series 5 - depending on what's actually in the folder. But this assumes you already know what's in the folder. In your case, you can feed in "q" to abort straight away, in which case you'd get a dump of the first level of hierarchy that
mrinfo came across. The problem there is that if there's only one patient in there, then it'll look at the study level, and if there's only one study, it'll look at the series level, and if there's only one series, it'll just run with that. So it's not necessarily going to give you a full breakdown of the contents, which is what you're after.
My guess is, you'll want to write a small app using the
DICOM::QuickScan class, which is designed to do a quick, but thorough scan through the full folder hierarchy and build the contents tree. You'd then be able to iterate through the list and print out whatever info you're after. It's not difficult, but understandably a lot easier if you're familiar with the MRtrix codebase... I'm happy to give you a hand with that if you want to pursue it.
As to the second question, selection by modality is a very unusual use case... My guess is if you can write an app to dump the contents, you can probably script something up to select the series you're interested by whatever criterion you're interested in. I think that would be the path of least resistance... I've often thought about allowing for DICOM selection at the command-line, but given how integrated DICOM handling within the MRtrix backend, it's hard to see how to do this cleanly - i.e. without adding options to all MRtrix apps in the process, etc...