Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate a variety of testing data and came up command_line version of sim_vim_sig.py #51

Closed
wants to merge 7 commits into from

Conversation

Unique-Usman
Copy link
Contributor

A clear and concise description of what you want to happen
Added this two files.
sim_ivim_sig_command_line.py - This is the command line version of the sim_vim_sig,py
sim_ivim_sig_mul_bval.py - This version is used for running multiple b_value which are stored in b_values.py

Various test files based on the multiple value of b_value in the b_values.py
├── generic_five.json
├── generic_four.json
├── generic_original.json
├── generic_three.json
├── generic_two.json

Also, the generic_original.json was supposed to be the same thing as generic.json. But, the result is not the same. I guess the generic.json was generate from another b_value different from the current one.

Also, @etpeterson what do you think about combining the three scripts(sim_ivim_sig_command_line.py, sim_ivim_sig_mul_bval.py, sim_ivim_sig.py) together instead of having multiple scirpts doing almost similar thing ? What we can do is to just have a single script that can be used as command line tools and is able to generate multiple value of test data based on the multiple b_values.

I will update the pr based on your feeedback and also come up with a documentation for running the scipt.

Link this PR to an issue [optional]

Fixes #41

Checklist

  • Self-review of changed code
  • Added automated tests where applicable
  • Update Docs & Guides

@etpeterson
Copy link
Contributor

Yes, I think it should just be one script, just changes to the original sim_ivim_sig.py would be great. One of the inputs could be a choice for bvalues to generate.

The change to generic.json looks like somehow the newline at the end got dropped, but the contents are the same. It's hard to say how this happened because it's difficult to see changes with the duplicated script. Once everything is all together then it'll be easier to look at the changes made.

@Unique-Usman
Copy link
Contributor Author

Unique-Usman commented Mar 5, 2024

A clear and concise description of what you want to happen
I have converted the script to one sim_ivim_sig.py.
Now it is able to take multiple bvalues through a json file. Also it can also take a single value through command line. The default value is also present.

Various test files based on the multiple value of b_value in the b_values.py
├── generic_0.json
├── generic_1.json
├── generic_2.json
├── generic_3.json
├── generic_4.json

Also, the generic_0.json was supposed to be the same thing as generic.json as I used the placeholder bvalue for it. But, the result is not the same. I guess the generic.json was generate from another b_value different from the current one. (I did not make any change to generic.json.)

There might also be a need for me to explain the changes made through a call or recording @etpeterson

I will update the pr based on your feeedback and also come up with a documentation for running the scipt.

Link this PR to an issue [optional]
Fixes #41

Checklist
Self-review of changed code
Added automated tests where applicable
Update Docs & Guides

Copy link
Contributor

@etpeterson etpeterson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting there. Several specific comments and it looks like one of the json files isn't correctly generated.

@@ -103,7 +105,7 @@ def contrast_curve_calc():
D[36] = 3e-3 # 36 artery
D[37] = 3e-3 # 37 vein
D[40] = 1.31e-3 # 40 asc lower intestine : Hai-Jing et al. doi: 10.1097/RCT.0000000000000926
D[41] = 1.31e-3 # 41 trans lower intestine : Hai-Jing et al. doi: 10.1097/RCT.0000000000000926
D[41] = 1.31e-3 # 41 trans lower# If conversion fails, try splitting the input as a lis intestine : Hai-Jing et al. doi: 10.1097/RCT.0000000000000926
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably accidental add?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it is accidental. Will correct it.

parser.add_argument("-b", "--bvalue", type=float,
nargs="+",
help="B values (list of of numbers)")
parser.add_argument("-bf", "--bvalues-file", metavar="FILE", type=parse_bvalues_file,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just -f for the short?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, noted. Will make changes to it.

@@ -0,0 +1,7 @@
[
[0.0, 1.0, 2.0, 5.0, 10.0, 20.0, 30.0, 50.0, 75.0, 100.0, 150.0, 250.0, 350.0, 400.0, 550.0, 700.0, 850.0, 1000.0],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than a list of lists perhaps an object so they can have names rather than just numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried object for the naming, but, we will have to enforce a pattern of naming on any one running the command for easy parsing.

Something like { generic_ : [], ...}. That is why I made it into a list of list. But, if you think object is better approach then I can change it to that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer objects. That way we have meaningful file names, like generic_short.json.

Some naming system would be good. I'm not sure what you mean "for easy parsing". I would imagine that people give either no name and they get all out or they give a name and they get that one out.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still pending as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I will change it to object.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your comment that the file changed. It looks like just a newline to me, am I wrong?

Along those lines, whichever file is a duplicate of this should be deduplicated. Your changes shouldn't alter the original bvalues in any way.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generic.json does not change. What I am saying is that, when I was trying to regenerate the generic.json using the current bvalues. I got different json values. So, that is why I said the generic.json might be generated from another bvalues different from the placeholders.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There shouldn't be changes to generic.json. I commented elsewhere on that. If it also changed in the main branch then perhaps, but I would be very surprised if that were the case.

Assuming there aren't changes though, we don't need two copies of generic.json. So confirming a duplicate and remove the original generic.json and point everything to the new one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still pending.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, I will take care of that.

else:
output_file = 'output_resp.nii.gz' # Replace with your desired output file name
bvalues = [[0., 1, 2, 5, 10, 20, 30, 50, 75, 100, 150, 250, 350, 400, 550, 700, 850, 1000]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems odd to have a double array, why is this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to make it a double array so that I can have one implementation with when the value is gotten from the files. Check line 420.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see. I guess it'll change with an object implementation anyway.

},
"config": {
"bvalues": [
43.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something isn't right with these bvalues.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh, that is true, I will change it. Those values I gave while testing the script in the command line.

@Unique-Usman
Copy link
Contributor Author

@etpeterson Kindly go through the comment, then I can make the necessary changes. Thank you.

@Unique-Usman
Copy link
Contributor Author

I changed the generic_0.json. Also correct the mistake in the script. Also changed the -bf option flag to -f flag.

What I was saying regarding the generic.json is that, the value in generic_0.json was supposed to be the same thing with the generic.json. Because, the bvalue for generic_0.json was the one bvalue in the repo. My suggestion is that, the bvalue used to generate generic.json is different from the one present in the repo.

@Unique-Usman Unique-Usman requested a review from etpeterson March 6, 2024 13:17
@etpeterson
Copy link
Contributor

What I was saying regarding the generic.json is that, the value in generic_0.json was supposed to be the same thing with the generic.json. Because, the bvalue for generic_0.json was the one bvalue in the repo. My suggestion is that, the bvalue used to generate generic.json is different from the one present in the repo.

Is this still different? We can see the bvalues used for generic.json in the file itself. And I can see they are the same as the default set you're using. Is it different on the main branch too? I would be surprised if it's different on the main branch so that would be a good place to check.

@Unique-Usman
Copy link
Contributor Author

Unique-Usman commented Mar 7, 2024

@etpeterson , I ran it on the unchaged main branch and it still give the different result from the generic.json. Yeah, the bvalues used is the same, something is wrong somewhere I guess.

@etpeterson
Copy link
Contributor

@etpeterson , I ran it on the unchaged main branch and it still give the different result from the generic.json. Yeah, the bvalues used is the same, something is wrong somewhere I guess.

That is surprising. What's the difference?

@Unique-Usman
Copy link
Contributor Author

All the decimal values
Screenshot from 2024-03-07 11-32-45

@etpeterson
Copy link
Contributor

This is strange. I don't know why that would change. The history doesn't show meaningful changes to that file. I'll give it a shot.

Also, unfortunately you have a merge conflict.

@etpeterson
Copy link
Contributor

I'm not sure what to say, but it worked for me, I got the same data in both. Here are my steps.

  • from the phantoms/MR_XCAT_qMRI folder
  • git checkout main
  • git pull
  • python sim_ivim_sig.py
  • let it run and in a minute or two it finished
  • git status shows no changes
  • diff generic.json ../../tests/IVIMmodels/unit_tests/generic.json shows no changes

@Unique-Usman
Copy link
Contributor Author

Did you move the utitlities to the phantoms/MR_XCAT_qMRI when running the code ?

@etpeterson
Copy link
Contributor

Did you move the utitlities to the phantoms/MR_XCAT_qMRI when running the code ?

No, if the pythonpath is set correctly it finds them where they are. Even if you pull the images manually I think the result should be the same though.

@Unique-Usman
Copy link
Contributor Author

Yeah, I was able to get the same data. But, do we want to add https://github.com/OSIPI/TF2.4_IVIM-MRI_CodeCollection/blob/main/phantoms/MR_XCAT_qMRI/sim_ivim_sig.py#L13 to the script. This keeps downloading all the data everytime.

@etpeterson
Copy link
Contributor

etpeterson commented Mar 8, 2024

This keeps downloading all the data everytime.

If that's the case then it sounds like a good issue to be fixed in a different pull request.

@etpeterson
Copy link
Contributor

etpeterson commented Mar 8, 2024

I'll try to actually run it later and test that, but the code looks good to me at the moment. Just a few changes still pending.

@etpeterson
Copy link
Contributor

Yeah, I was able to get the same data

What was the problem? Is it something that we can fix with some instructions or code?

@Unique-Usman
Copy link
Contributor Author

This keeps downloading all the data everytime.

If that's the case then it sounds like a good issue to be fixed in a different pull request.

I think, if possible, we should have the downloading of data separately. Then, in the documentation for running the code that I will be providing, I will mention it there.

@Unique-Usman
Copy link
Contributor Author

f that's the case then it sounds like a good issue to be fixed in a different pull request.

I really think it is some mix up somewhere, probably I deleted or add some code mistakenly. I resolved the problem by rewriting the code from the start.

@etpeterson
Copy link
Contributor

I think, if possible, we should have the downloading of data separately. Then, in the documentation for running the code that I will be providing, I will mention it there.

We shouldn't try to reimplement git-lfs here, but also a simple check to see if the requisite files are present and if not then download seems pretty easy. If it's in the document and in the code then requiring two steps is fine.

@Unique-Usman Unique-Usman deleted the usman branch March 12, 2024 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate a variety of testing data
2 participants