Skip to content

[general] self.output_directory initialisation issue #40

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

Closed
manuegrx opened this issue Jun 16, 2023 · 6 comments
Closed

[general] self.output_directory initialisation issue #40

manuegrx opened this issue Jun 16, 2023 · 6 comments

Comments

@manuegrx
Copy link
Contributor

As explain in #22 we need to add a sub-folder in derived_data for each subject for some brick (as in EstimateModel).

The idea was to redefine self.output_directory path in each brick.
For example in the EstmiateModel brick :

          if self.output_directory:
               # Change output_directory for this process in order to
               # use a specific directory for each analysis

               if os.path.dirname(
                   spm_mat_dir
               ) == self.output_directory and "data" in os.path.basename(
                   spm_mat_dir
               ):
                   # if spm_mat already in a subfolder for a analysis
                   out_directory = spm_mat_dir
               else:
                   # if spm_mat file not in a subfolder(for e.g spm_mat
                   # file in download data)
                   sub_name = get_dbFieldValue(
                       self.project, self.spm_mat_file, "PatientName"
                   )
                   if sub_name is None:
                       print(
                           "Please, fill 'PatientName' tag "
                           "in the database for SPM file"
                       )
                       return self.make_initResult()

                   out_directory = os.path.join(
                       self.output_directory, sub_name + "_data"
                   )

                   if not os.path.exists(out_directory):
                       os.mkdir(out_directory)
               self.output_directory = out_directory
           else:
               print("No output_directory was found...!\n")
               return self.make_initResult()

It is working correctly when using the brick alone or in a pipeline.

However, if we are using iteration there is an issue :

  • at the begging of the brick for the second subject : self.output_directory = ".../data/derived_data/sub-01" and not self.output_directory = ".../data/derived_data/"
  • the outputs are therefore created in ".../data/derived_data/sub-01/sub-02"
@manuegrx
Copy link
Contributor Author

manuegrx commented Jul 5, 2023

To quickly reproduce the issue, for example, in a new project:

  • add two time the test subject alej, one time with the name 001 and one time with the name 002
  • add (using the "add document" button) the regressor physio (regressor_physio_EtC02_ctl.mat)
  • for each subject (001 and 002) run level1design brick (only filled the sess_scans parameter with the scan and the sess_mtlti_reg parameter with the regressor)
  • For the estimateModel brick, click on "Iterate pipeline" and choose to iterate over spm_mat_file. Select both SPM.mat file created before and run the brick

(It will be better to test also the iteration with a pipeline with level1design, estimateModel and EstimateContrast brick but there is currently an issue to iterate Level1design brick)

@manuegrx
Copy link
Contributor Author

manuegrx commented Jul 5, 2023

The issue also appears when you stay on the same pipeline/ brick to do a second subject

To reproduce:

  • add two time the test subject alej, one time with the name 001 and one time with the name 002
  • add (using the "add document" button) the regressor physio (regressor_physio_EtC02_ctl.mat)
  • for each subject (001 and 002) run level1design brick (only filled the sess_scans parameter with the scan and the sess_mtlti_reg parameter with the regressor)
  • Run EstimateModel for subject 001
  • Stay on the same pipeline and change the smp_mat_file for subject 002. Run the brick

@servoz
Copy link
Contributor

servoz commented Jul 10, 2023

To reproduce:

add two time the test subject alej, one time with the name 001 and one time with the name 002
add (using the "add document" button) the regressor physio (regressor_physio_EtC02_ctl.mat)
for each subject (001 and 002) run level1design brick (only filled the sess_scans parameter with the scan and the sess_mtlti_reg parameter with the regressor)
Run EstimateModel for subject 001
Stay on the same pipeline and change the smp_mat_file for subject 002. Run the brick

OK I reproduce ... I start to look for a fix ..

@servoz
Copy link
Contributor

servoz commented Jul 10, 2023

I made a fix for the last To reproduce case.

@manuegrx, can you please try on your side with different cases.

I also need to do some tests on my end.

@manuegrx
Copy link
Contributor Author

It works on my side for both issues (it is okay when I stay on the same pipeline/ brick to do a second subject and it is okay when I iterated ) :)

Thanks !

@servoz
Copy link
Contributor

servoz commented Jul 11, 2023

Thank you.
As it's good for you, I'm going to close this ticket after a final survey.
I think we can do better. I need some time for a final fix and testing with bricks that are not an instance of ProcessMIA.

@servoz servoz closed this as completed Jul 11, 2023
servoz added a commit to populse/populse_mia that referenced this issue Oct 2, 2024
servoz added a commit to populse/populse_mia that referenced this issue Oct 2, 2024
servoz added a commit to populse/populse_mia that referenced this issue Oct 2, 2024
servoz added a commit to populse/populse_mia that referenced this issue Oct 2, 2024
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

No branches or pull requests

2 participants