MNIST expects a specific format, so you would need to store your data in the same format and name accordingly.
The usual approach would be to e.g. use ImageFolder, if you are loading single image files, or a custom Dataset.
What kind of data do you have?
Did you store the x-ray images in some kind of binary data or do you have each image stored separately?
In the latter case, have a look at the Data Loading Tutorial to see how to create a custom Dataset.