-
Notifications
You must be signed in to change notification settings - Fork 22
Integration of CPCA package, removing NPR code #424
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
base: master
Are you sure you want to change the base?
Conversation
|
""" WalkthroughThe changes overhaul the analysis pipeline by replacing the previous Neural Prior Recovery (NPR) method with a new Complementary Principal Component Analysis (CPCA) approach. This includes new CPCA modeling and reporting modules, updates to workflows, interfaces, diagnostics, parser options, and test scripts, all adopting CPCA parameters, outputs, and naming conventions. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI/Parser
participant Workflow
participant CPCA_Modeling
participant CPCA_Report
User->>CLI/Parser: Provide CPCA parameters via --CPCA
CLI/Parser->>Workflow: Pass CPCA options
Workflow->>CPCA_Modeling: Run cpca_auto(X, C_prior, CPCA_dict)
CPCA_Modeling->>CPCA_Report: Generate report and diagnostics
CPCA_Modeling->>Workflow: Return CPCA outputs (maps, timecourses, report)
Workflow->>User: Save/output CPCA results
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 13
🧹 Nitpick comments (22)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py (1)
83-83: Fix indentation formatting issue.The line has incorrect indentation according to static analysis.
Apply this diff to fix the indentation:
- 'DR_BOLD', 'CPCA_maps', 'prior_maps', 'seed_map_list'] + 'DR_BOLD', 'CPCA_maps', 'prior_maps', 'seed_map_list']rabies/analysis_pkg/diagnosis_pkg/interfaces.py (1)
229-430: Fix multiple formatting issues throughout the CPCA section.Static analysis identified numerous formatting issues including missing whitespace around operators and after commas.
Apply these formatting fixes:
- FC_maps_dict['CPCA']=[] + FC_maps_dict['CPCA'] = [] - DR_conf_corr_dict['CPCA']=[] + DR_conf_corr_dict['CPCA'] = [] - [scan_data['DR_network_time'],scan_data['CPCA_network_time'],scan_data['SBC_network_time']], + [scan_data['DR_network_time'], scan_data['CPCA_network_time'], scan_data['SBC_network_time']], - ['DR','CPCA','SBC']): + ['DR', 'CPCA', 'SBC']): - CPCA_maps_list=np.array(FC_maps_dict['CPCA']) + CPCA_maps_list = np.array(FC_maps_dict['CPCA']) - if CPCA_maps_list.shape[1]>0: + if CPCA_maps_list.shape[1] > 0:And continue with similar spacing fixes throughout the function.
rabies/analysis_pkg/analysis_wf.py (1)
119-127: Fix formatting issues in CPCA node configuration.Static analysis identified spacing issues around operators and parameters.
Apply these formatting fixes:
- if opts.CPCA['n']>-1: + if opts.CPCA['n'] > -1: - CPCA_node = pe.Node(ComplementaryPCA( - CPCA_dict=opts.CPCA, - prior_bold_idx = opts.prior_bold_idx, + CPCA_node = pe.Node(ComplementaryPCA( + CPCA_dict=opts.CPCA, + prior_bold_idx=opts.prior_bold_idx,rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py (2)
111-111: Fix object identity comparison.Use
is notinstead ofnot ... is Nonefor better clarity and correctness.Apply this diff:
- if not analysis_dict['CPCA_prior_filename'] is None: + if analysis_dict['CPCA_prior_filename'] is not None:
147-147: Fix spacing issues in function calls.Add missing whitespace after commas for better readability.
Apply these formatting fixes:
- del temporal_info['DR_all'], temporal_info['DR_bold'],temporal_info['DR_confound'],temporal_info['CPCA_time'],temporal_info['SBC_time'] + del temporal_info['DR_all'], temporal_info['DR_bold'], temporal_info['DR_confound'], temporal_info['CPCA_time'], temporal_info['SBC_time'] - [temporal_info['DR_confound'], temporal_info['DR_bold'],temporal_info['SBC_time'],temporal_info['CPCA_time']], + [temporal_info['DR_confound'], temporal_info['DR_bold'], temporal_info['SBC_time'], temporal_info['CPCA_time']], - ['DR confounds', 'DR networks','SBC networks','CPCA networks'], + ['DR confounds', 'DR networks', 'SBC networks', 'CPCA networks'],Also applies to: 387-388
rabies/analysis_pkg/main_wf.py (2)
178-182: Fix formatting issues in function signature and dictionaryWhile the NPR to CPCA transition is correct, there are formatting issues that should be addressed.
-def prep_analysis_dict(seed_map_files, seed_timecourse_csv, dual_regression_nii, dual_regression_timecourse_csv, CPCA_prior_timecourse_csv, CPCA_extra_timecourse_csv, CPCA_prior_filename, CPCA_extra_filename): - return {'seed_map_files':seed_map_files, 'seed_timecourse_csv':seed_timecourse_csv, 'dual_regression_nii':dual_regression_nii, 'dual_regression_timecourse_csv':dual_regression_timecourse_csv, - 'CPCA_prior_timecourse_csv':CPCA_prior_timecourse_csv, 'CPCA_extra_timecourse_csv':CPCA_extra_timecourse_csv, - 'CPCA_prior_filename':CPCA_prior_filename, 'CPCA_extra_filename':CPCA_extra_filename} +def prep_analysis_dict(seed_map_files, seed_timecourse_csv, dual_regression_nii, dual_regression_timecourse_csv, CPCA_prior_timecourse_csv, CPCA_extra_timecourse_csv, CPCA_prior_filename, CPCA_extra_filename): + return {'seed_map_files': seed_map_files, 'seed_timecourse_csv': seed_timecourse_csv, 'dual_regression_nii': dual_regression_nii, 'dual_regression_timecourse_csv': dual_regression_timecourse_csv, + 'CPCA_prior_timecourse_csv': CPCA_prior_timecourse_csv, 'CPCA_extra_timecourse_csv': CPCA_extra_timecourse_csv, + 'CPCA_prior_filename': CPCA_prior_filename, 'CPCA_extra_filename': CPCA_extra_filename}
212-212: Fix spacing around comparison operator-if analysis_opts.CPCA['n']>-1: +if analysis_opts.CPCA['n'] > -1:rabies/analysis_pkg/cpca/modeling.py (2)
44-48: Simplify nested if statements-if lim < tol: - if verbose > 1: - print(str(i)+' iterations to converge.') - break +if lim < tol: + if verbose > 1: + print(f'{i} iterations to converge.') + break
74-77: Remove unused variable assignmentThe variable
n_tis assigned but never used.s_idx = np.where(np.array(sequence)=='s')[0] t_idx = np.where(np.array(sequence)=='t')[0] n_s = len(s_idx) -n_t = len(t_idx) +# n_t = len(t_idx) # Not usedrabies/parser.py (2)
1106-1110: Fix formatting in parse_argument call-opts.CPCA = parse_argument(opt=opts.CPCA, - key_value_pairs = {'n':int, 'Wt_n':int, 'min_prior_sim':float, - 'Dc_C_thresh':float, 'Dc_W_thresh':float}, - defaults = {'n':-1,'Wt_n':0,'min_prior_sim':-1,'Dc_C_thresh':-1,'Dc_W_thresh':-1}, - name='CPCA') +opts.CPCA = parse_argument(opt=opts.CPCA, + key_value_pairs={'n': int, 'Wt_n': int, 'min_prior_sim': float, + 'Dc_C_thresh': float, 'Dc_W_thresh': float}, + defaults={'n': -1, 'Wt_n': 0, 'min_prior_sim': -1, 'Dc_C_thresh': -1, 'Dc_W_thresh': -1}, + name='CPCA')
1152-1152: Update scan_QC_thresholds parsing for CPCAThe parsing correctly adds CPCA to the allowed keys. Fix the membership test syntax for better readability.
-for key in ['SBC','DR','CPCA','Dice','Conf','Amp']: +for key in ['SBC', 'DR', 'CPCA', 'Dice', 'Conf', 'Amp']:-if not key in ['SBC','DR','CPCA']: - raise ValueError(f"The key '{key}' from --scan_QC_thresholds is invalid. Must be among 'SBC','DR','CPCA'.") +if key not in ['SBC', 'DR', 'CPCA']: + raise ValueError(f"The key '{key}' from --scan_QC_thresholds is invalid. Must be among 'SBC', 'DR', 'CPCA'.")Also applies to: 1175-1176
rabies/analysis_pkg/cpca/report.py (4)
6-14: Simplify conditional assignment and fix formatting-def cosine_similarity(X,Y=None): +def cosine_similarity(X, Y=None): # estimate cosine similarity across the columns of X and Y combined - if Y is None: - arr = X.copy() - else: - arr = np.concatenate((X,Y),axis=1) - arr /= np.sqrt((arr ** 2).sum(axis=0)) # first normalize from l2-norm - Sc = (arr.T.dot(arr)) # then derive vector product across columns + arr = X.copy() if Y is None else np.concatenate((X, Y), axis=1) + arr /= np.sqrt((arr ** 2).sum(axis=0)) # first normalize from l2-norm + Sc = arr.T.dot(arr) # then derive vector product across columns return Sc
17-36: Fix formatting in function signature-def gen_report(X,C_prior, Cs, min_prior_sim=None, Dc_W_thresh=None, Dc_C_thresh=None): +def gen_report(X, C_prior, Cs, min_prior_sim=None, Dc_W_thresh=None, Dc_C_thresh=None):Also fix the formatting issues in the function calls:
-Snet_s_l,Snet_t_l,prior_sim_l,Dc_Cnet,Dc_Wnet,R2_s,R2_t = evaluate_fit(X,C_prior,Cs) +Snet_s_l, Snet_t_l, prior_sim_l, Dc_Cnet, Dc_Wnet, R2_s, R2_t = evaluate_fit(X, C_prior, Cs)
39-126: Consider breaking down this long functionThe
evaluate_fitfunction is quite long with 42 local variables and 53 statements. Consider refactoring it into smaller, more focused functions for better maintainability.Would you like me to help refactor this function into smaller, more manageable pieces?
152-155: Simplify conditional assignment-if len(Dc_idx)==0: - last_Dc_idx = 0 -else: - last_Dc_idx = Dc_idx.max() +last_Dc_idx = 0 if len(Dc_idx) == 0 else Dc_idx.max()rabies/analysis_pkg/analysis_functions.py (7)
188-197: Add missing blank lines before class definitionPEP 8 requires two blank lines before class definitions at the module level.
) + class ComplementaryPCAInputSpec(BaseInterfaceInputSpec):
219-240: Consider refactoring this method to reduce complexityThis method has 43 local variables and 58 statements, making it difficult to maintain and test. Consider extracting logical sections into separate helper methods.
Suggested refactoring approach:
- Extract data loading logic (lines 227-234)
- Extract CPCA parameter preparation (lines 241-251)
- Extract report generation (lines 256-261)
- Extract component saving logic (lines 274-290)
241-251: Fix whitespace around operatorsAdd spaces around comparison operators for better readability.
CPCA_dict = self.inputs.CPCA_dict min_prior_sim = CPCA_dict['min_prior_sim'] - if min_prior_sim<0: + if min_prior_sim < 0: min_prior_sim = None Dc_C_thresh = CPCA_dict['Dc_C_thresh'] - if Dc_C_thresh<0: + if Dc_C_thresh < 0: Dc_C_thresh = None Dc_W_thresh = CPCA_dict['Dc_W_thresh'] - if Dc_W_thresh<0: + if Dc_W_thresh < 0: Dc_W_thresh = None
252-254: Fix formatting in function callAdd spaces after commas and fix indentation for better readability.
- Cnet,Wnet,Cs,Ws,Ct,Wt,C,W,fig_list = cpca_auto(X=timeseries, C_prior=C_prior, - N_max=CPCA_dict['n'], Wt_n=CPCA_dict['Wt_n'], min_prior_sim=min_prior_sim, - Dc_W_thresh=Dc_W_thresh, Dc_C_thresh=Dc_C_thresh) + Cnet, Wnet, Cs, Ws, Ct, Wt, C, W, fig_list = cpca_auto( + X=timeseries, C_prior=C_prior, + N_max=CPCA_dict['n'], Wt_n=CPCA_dict['Wt_n'], min_prior_sim=min_prior_sim, + Dc_W_thresh=Dc_W_thresh, Dc_C_thresh=Dc_C_thresh)
256-261: Remove unnecessary f-string prefixThe f-string on line 256 doesn't contain any placeholders.
- report_folder = os.path.abspath(f'CPCA_report/') + report_folder = os.path.abspath('CPCA_report/')
264-272: Fix formatting issuesAdd missing whitespace after commas and before inline comments.
# put together the spatial and temporal extra components - W_extra = np.concatenate((Ws,Wt), axis=1) + W_extra = np.concatenate((Ws, Wt), axis=1) if network_weighting=='relative': - Cnet /= np.sqrt((Cnet ** 2).mean(axis=0)) # normalization, so that the scale is in C - Cs /= np.sqrt((Cs ** 2).mean(axis=0)) # normalization, so that the scale is in C - Ct /= np.sqrt((Ct ** 2).mean(axis=0)) # normalization, so that the scale is in C + Cnet /= np.sqrt((Cnet ** 2).mean(axis=0)) # normalization, so that the scale is in C + Cs /= np.sqrt((Cs ** 2).mean(axis=0)) # normalization, so that the scale is in C + Ct /= np.sqrt((Ct ** 2).mean(axis=0)) # normalization, so that the scale is in C - C_extra = np.concatenate((Cs,Ct), axis=1) + C_extra = np.concatenate((Cs, Ct), axis=1)
280-290: Fix formatting in function callsAdd missing whitespace after commas in function calls.
CPCA_prior_filename = os.path.abspath(filename_split[0]+'_CPCA_prior.nii.gz') - sitk.WriteImage(recover_4D(mask_file,C_fit.T, bold_file), CPCA_prior_filename) + sitk.WriteImage(recover_4D(mask_file, C_fit.T, bold_file), CPCA_prior_filename) - if C_extra.shape[1]>0: # store extra components if at least 1 was fitted + if C_extra.shape[1] > 0: # store extra components if at least 1 was fitted CPCA_extra_filename = os.path.abspath(filename_split[0]+'_CPCA_extra.nii.gz') - sitk.WriteImage(recover_4D(mask_file,C_extra.T, bold_file), CPCA_extra_filename) + sitk.WriteImage(recover_4D(mask_file, C_extra.T, bold_file), CPCA_extra_filename) else: - empty_img = sitk.GetImageFromArray(np.empty([1,1])) + empty_img = sitk.GetImageFromArray(np.empty([1, 1]))
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
rabies/analysis_pkg/analysis_functions.py(2 hunks)rabies/analysis_pkg/analysis_math.py(0 hunks)rabies/analysis_pkg/analysis_wf.py(2 hunks)rabies/analysis_pkg/cpca/modeling.py(1 hunks)rabies/analysis_pkg/cpca/report.py(1 hunks)rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py(7 hunks)rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py(1 hunks)rabies/analysis_pkg/diagnosis_pkg/interfaces.py(4 hunks)rabies/analysis_pkg/main_wf.py(2 hunks)rabies/parser.py(6 hunks)scripts/error_check_rabies.py(2 hunks)scripts/generate_graph.py(1 hunks)
💤 Files with no reviewable changes (1)
- rabies/analysis_pkg/analysis_math.py
🧰 Additional context used
🪛 Flake8 (7.2.0)
rabies/analysis_pkg/diagnosis_pkg/interfaces.py
[error] 229-229: missing whitespace around operator
(E225)
[error] 230-230: missing whitespace around operator
(E225)
[error] 232-232: missing whitespace around operator
(E225)
[error] 233-233: missing whitespace around operator
(E225)
[error] 234-234: missing whitespace around operator
(E225)
[error] 258-258: missing whitespace after ','
(E231)
[error] 259-259: missing whitespace after ','
(E231)
[error] 259-259: missing whitespace after ','
(E231)
[error] 260-260: visually indented line with same indent as next logical line
(E129)
[error] 260-260: missing whitespace after ','
(E231)
[error] 260-260: missing whitespace after ','
(E231)
[error] 403-403: too many blank lines (2)
(E303)
[error] 403-403: missing whitespace around operator
(E225)
[error] 404-404: missing whitespace around operator
(E225)
[error] 407-407: missing whitespace after ','
(E231)
[error] 407-407: missing whitespace after ','
(E231)
[error] 417-417: missing whitespace after ','
(E231)
[error] 417-417: missing whitespace after ','
(E231)
[error] 417-417: at least two spaces before inline comment
(E261)
[error] 419-419: missing whitespace around operator
(E225)
[error] 421-421: missing whitespace after ','
(E231)
[error] 421-421: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 422-422: missing whitespace after ','
(E231)
[error] 425-425: missing whitespace around operator
(E225)
[error] 427-427: missing whitespace after ','
(E231)
[error] 428-428: missing whitespace after ','
(E231)
[error] 430-430: missing whitespace after ','
(E231)
[error] 430-430: missing whitespace after ','
(E231)
[error] 430-430: missing whitespace after ','
(E231)
[error] 430-430: missing whitespace after ','
(E231)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py
[error] 83-83: continuation line over-indented for visual indent
(E127)
rabies/analysis_pkg/analysis_wf.py
[error] 19-19: missing whitespace after ','
(E231)
[error] 119-119: missing whitespace around operator
(E225)
[error] 124-124: unexpected spaces around keyword / parameter equals
(E251)
[error] 124-124: unexpected spaces around keyword / parameter equals
(E251)
rabies/analysis_pkg/main_wf.py
[error] 179-179: missing whitespace after ':'
(E231)
[error] 179-179: missing whitespace after ':'
(E231)
[error] 179-179: missing whitespace after ':'
(E231)
[error] 179-179: missing whitespace after ':'
(E231)
[error] 180-180: missing whitespace after ':'
(E231)
[error] 180-180: missing whitespace after ':'
(E231)
[error] 181-181: missing whitespace after ':'
(E231)
[error] 181-181: missing whitespace after ':'
(E231)
[error] 212-212: missing whitespace around operator
(E225)
scripts/generate_graph.py
[error] 4-4: 'SimpleITK as sitk' imported but unused
(F401)
[error] 5-5: 'nipype.logging' imported but unused
(F401)
[error] 5-5: 'nipype.config' imported but unused
(F401)
[error] 6-6: 'from rabies.boilerplate import *' used; unable to detect undefined names
(F403)
[error] 7-7: missing whitespace after ','
(E231)
[error] 8-8: 'from rabies.run_main import *' used; unable to detect undefined names
(F403)
[error] 21-21: at least two spaces before inline comment
(E261)
[error] 23-23: do not use bare 'except'
(E722)
[error] 30-30: 'prep_logging' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 33-33: 'install_DSURQE' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 36-36: too many blank lines (2)
(E303)
[error] 44-44: missing whitespace around operator
(E225)
[error] 44-44: missing whitespace around operator
(E225)
[error] 45-45: f-string is missing placeholders
(F541)
[error] 51-51: 'preprocess' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 53-53: 'confound_correction' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 55-55: 'analysis' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 70-70: continuation line under-indented for visual indent
(E128)
[error] 82-82: too many blank lines (3)
(E303)
[error] 82-82: module level import not at top of file
(E402)
[error] 84-84: module level import not at top of file
(E402)
[error] 87-87: too many leading '#' for block comment
(E266)
[error] 92-92: too many leading '#' for block comment
(E266)
[error] 94-94: f-string is missing placeholders
(F541)
[error] 94-94: missing whitespace after ','
(E231)
[error] 96-96: block comment should start with '# '
(E265)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
[error] 147-147: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 387-387: missing whitespace after ','
(E231)
[error] 387-387: missing whitespace after ','
(E231)
[error] 388-388: missing whitespace after ','
(E231)
[error] 388-388: missing whitespace after ','
(E231)
rabies/analysis_pkg/cpca/modeling.py
[error] 32-32: missing whitespace after ','
(E231)
[error] 36-36: too many leading '#' for block comment
(E266)
[error] 49-49: missing whitespace after ','
(E231)
[error] 49-49: missing whitespace after ','
(E231)
[error] 51-51: expected 2 blank lines, found 1
(E302)
[error] 51-51: unexpected spaces around keyword / parameter equals
(E251)
[error] 51-51: unexpected spaces around keyword / parameter equals
(E251)
[error] 51-51: missing whitespace after ','
(E231)
[error] 51-51: missing whitespace after ','
(E231)
[error] 51-51: missing whitespace after ','
(E231)
[error] 56-56: missing whitespace around operator
(E225)
[error] 56-56: at least two spaces before inline comment
(E261)
[error] 60-60: at least two spaces before inline comment
(E261)
[error] 63-63: at least two spaces before inline comment
(E261)
[error] 67-67: missing whitespace after ','
(E231)
[error] 67-67: missing whitespace after ','
(E231)
[error] 68-68: missing whitespace after ','
(E231)
[error] 68-68: at least two spaces before inline comment
(E261)
[error] 71-71: missing whitespace after ','
(E231)
[error] 72-72: missing whitespace after ','
(E231)
[error] 74-74: missing whitespace around operator
(E225)
[error] 75-75: missing whitespace around operator
(E225)
[error] 77-77: local variable 'n_t' is assigned to but never used
(F841)
[error] 79-79: missing whitespace after ','
(E231)
[error] 80-80: missing whitespace after ','
(E231)
[error] 83-83: missing whitespace after ','
(E231)
[error] 86-86: at least two spaces before inline comment
(E261)
[error] 87-87: at least two spaces before inline comment
(E261)
[error] 88-88: at least two spaces before inline comment
(E261)
[error] 89-89: missing whitespace after ','
(E231)
[error] 93-93: missing whitespace after ','
(E231)
[error] 94-94: missing whitespace after ','
(E231)
[error] 95-95: missing whitespace after ','
(E231)
[error] 98-98: too many blank lines (2)
(E303)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 101-101: unexpected spaces around keyword / parameter equals
(E251)
[error] 101-101: unexpected spaces around keyword / parameter equals
(E251)
[error] 101-101: missing whitespace after ','
(E231)
[error] 101-101: missing whitespace after ','
(E231)
[error] 101-101: missing whitespace after ','
(E231)
[error] 106-106: missing whitespace around operator
(E225)
[error] 106-106: at least two spaces before inline comment
(E261)
[error] 115-115: at least two spaces before inline comment
(E261)
[error] 118-118: missing whitespace after ','
(E231)
[error] 118-118: missing whitespace after ','
(E231)
[error] 121-121: missing whitespace after ','
(E231)
[error] 121-121: at least two spaces before inline comment
(E261)
[error] 123-123: missing whitespace after ','
(E231)
[error] 123-123: at least two spaces before inline comment
(E261)
[error] 125-125: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 128-128: missing whitespace around operator
(E225)
[error] 129-129: missing whitespace around operator
(E225)
[error] 131-131: local variable 'n_t' is assigned to but never used
(F841)
[error] 133-133: missing whitespace after ','
(E231)
[error] 134-134: missing whitespace after ','
(E231)
[error] 137-137: missing whitespace after ','
(E231)
[error] 140-140: at least two spaces before inline comment
(E261)
[error] 141-141: at least two spaces before inline comment
(E261)
[error] 142-142: at least two spaces before inline comment
(E261)
[error] 143-143: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 148-148: missing whitespace after ','
(E231)
[error] 149-149: missing whitespace after ','
(E231)
[error] 152-152: too many blank lines (2)
(E303)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 160-160: missing whitespace around operator
(E225)
[error] 164-164: missing whitespace around operator
(E225)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 174-174: comparison to None should be 'if cond is None:'
(E711)
[error] 174-174: missing whitespace around operator
(E225)
[error] 179-179: missing whitespace after ','
(E231)
[error] 179-179: missing whitespace after ','
(E231)
[error] 181-181: missing whitespace after ','
(E231)
[error] 182-182: missing whitespace after ','
(E231)
[error] 184-184: missing whitespace after ','
(E231)
[error] 185-185: missing whitespace after ','
(E231)
[error] 189-189: missing whitespace after ','
(E231)
[error] 192-192: at least two spaces before inline comment
(E261)
[error] 193-193: at least two spaces before inline comment
(E261)
[error] 194-194: at least two spaces before inline comment
(E261)
[error] 195-195: missing whitespace after ','
(E231)
[error] 199-199: missing whitespace after ','
(E231)
[error] 200-200: missing whitespace after ','
(E231)
[error] 201-201: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
rabies/analysis_pkg/analysis_functions.py
[error] 188-188: expected 2 blank lines, found 1
(E302)
[error] 198-198: expected 2 blank lines, found 1
(E302)
[error] 243-243: missing whitespace around operator
(E225)
[error] 246-246: missing whitespace around operator
(E225)
[error] 249-249: missing whitespace around operator
(E225)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 252-252: missing whitespace after ','
(E231)
[error] 253-253: continuation line under-indented for visual indent
(E128)
[error] 254-254: continuation line under-indented for visual indent
(E128)
[error] 256-256: f-string is missing placeholders
(F541)
[error] 264-264: missing whitespace after ','
(E231)
[error] 266-266: missing whitespace around operator
(E225)
[error] 267-267: at least two spaces before inline comment
(E261)
[error] 268-268: at least two spaces before inline comment
(E261)
[error] 269-269: at least two spaces before inline comment
(E261)
[error] 271-271: missing whitespace after ','
(E231)
[error] 281-281: missing whitespace after ','
(E231)
[error] 283-283: missing whitespace around operator
(E225)
[error] 283-283: at least two spaces before inline comment
(E261)
[error] 285-285: missing whitespace after ','
(E231)
[error] 287-287: missing whitespace after ','
(E231)
rabies/parser.py
[error] 986-986: unexpected spaces around keyword / parameter equals
(E251)
[error] 987-987: continuation line unaligned for hanging indent
(E131)
[error] 1107-1107: continuation line under-indented for visual indent
(E128)
[error] 1107-1107: unexpected spaces around keyword / parameter equals
(E251)
[error] 1107-1107: unexpected spaces around keyword / parameter equals
(E251)
[error] 1107-1107: missing whitespace after ':'
(E231)
[error] 1107-1107: missing whitespace after ':'
(E231)
[error] 1107-1107: missing whitespace after ':'
(E231)
[error] 1108-1108: missing whitespace after ':'
(E231)
[error] 1108-1108: missing whitespace after ':'
(E231)
[error] 1109-1109: unexpected spaces around keyword / parameter equals
(E251)
[error] 1109-1109: unexpected spaces around keyword / parameter equals
(E251)
[error] 1109-1109: missing whitespace after ':'
(E231)
[error] 1109-1109: missing whitespace after ','
(E231)
[error] 1109-1109: missing whitespace after ':'
(E231)
[error] 1109-1109: missing whitespace after ','
(E231)
[error] 1109-1109: missing whitespace after ':'
(E231)
[error] 1109-1109: missing whitespace after ','
(E231)
[error] 1109-1109: missing whitespace after ':'
(E231)
[error] 1109-1109: missing whitespace after ','
(E231)
[error] 1109-1109: missing whitespace after ':'
(E231)
[error] 1152-1152: missing whitespace after ','
(E231)
[error] 1152-1152: missing whitespace after ','
(E231)
[error] 1152-1152: missing whitespace after ','
(E231)
[error] 1152-1152: missing whitespace after ','
(E231)
[error] 1152-1152: missing whitespace after ','
(E231)
[error] 1175-1175: test for membership should be 'not in'
(E713)
[error] 1175-1175: missing whitespace after ','
(E231)
[error] 1175-1175: missing whitespace after ','
(E231)
rabies/analysis_pkg/cpca/report.py
[error] 6-6: missing whitespace after ','
(E231)
[error] 11-11: missing whitespace after ','
(E231)
[error] 11-11: missing whitespace after ','
(E231)
[error] 12-12: at least two spaces before inline comment
(E261)
[error] 13-13: at least two spaces before inline comment
(E261)
[error] 17-17: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 26-26: missing whitespace after ','
(E231)
[error] 30-30: missing whitespace after ','
(E231)
[error] 30-30: missing whitespace after ','
(E231)
[error] 30-30: missing whitespace after ','
(E231)
[error] 30-30: missing whitespace after ','
(E231)
[error] 30-30: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 34-34: missing whitespace after ','
(E231)
[error] 35-35: continuation line under-indented for visual indent
(E128)
[error] 35-35: missing whitespace after ','
(E231)
[error] 35-35: missing whitespace after ','
(E231)
[error] 35-35: missing whitespace after ','
(E231)
[error] 35-35: missing whitespace after ','
(E231)
[error] 35-35: missing whitespace after ','
(E231)
[error] 39-39: missing whitespace after ','
(E231)
[error] 39-39: missing whitespace after ','
(E231)
[error] 42-42: missing whitespace after ','
(E231)
[error] 42-42: at least two spaces before inline comment
(E261)
[error] 46-46: missing whitespace after ','
(E231)
[error] 47-47: at least two spaces before inline comment
(E261)
[error] 49-49: missing whitespace after ','
(E231)
[error] 64-64: missing whitespace after ','
(E231)
[error] 68-68: missing whitespace after ','
(E231)
[error] 68-68: missing whitespace after ','
(E231)
[error] 72-72: missing whitespace after ','
(E231)
[error] 73-73: at least two spaces before inline comment
(E261)
[error] 89-89: missing whitespace after ','
(E231)
[error] 89-89: missing whitespace after ','
(E231)
[error] 89-89: missing whitespace after ','
(E231)
[error] 89-89: missing whitespace after ','
(E231)
[error] 99-99: too many blank lines (2)
(E303)
[error] 102-102: missing whitespace after ','
(E231)
[error] 102-102: missing whitespace after ','
(E231)
[error] 103-103: missing whitespace after ','
(E231)
[error] 103-103: missing whitespace after ','
(E231)
[error] 109-109: missing whitespace after ','
(E231)
[error] 109-109: missing whitespace after ','
(E231)
[error] 109-109: missing whitespace after ','
(E231)
[error] 109-109: missing whitespace after ','
(E231)
[error] 110-110: missing whitespace after ','
(E231)
[error] 110-110: missing whitespace after ','
(E231)
[error] 110-110: missing whitespace after ','
(E231)
[error] 110-110: missing whitespace after ','
(E231)
[error] 113-113: missing whitespace after ','
(E231)
[error] 113-113: missing whitespace after ','
(E231)
[error] 114-114: missing whitespace after ','
(E231)
[error] 114-114: missing whitespace after ','
(E231)
[error] 119-119: missing whitespace after ','
(E231)
[error] 120-120: missing whitespace after ','
(E231)
[error] 120-120: missing whitespace after ','
(E231)
[error] 121-121: missing whitespace after ','
(E231)
[error] 121-121: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 129-129: missing whitespace after ','
(E231)
[error] 129-129: missing whitespace after ','
(E231)
[error] 129-129: missing whitespace after ','
(E231)
[error] 129-129: missing whitespace after ','
(E231)
[error] 129-129: missing whitespace after ','
(E231)
[error] 133-133: test for object identity should be 'is not'
(E714)
[error] 135-135: missing whitespace around operator
(E225)
[error] 136-136: missing whitespace around operator
(E225)
[error] 136-136: at least two spaces before inline comment
(E261)
[error] 139-139: at least two spaces before inline comment
(E261)
[error] 140-140: missing whitespace around operator
(E225)
[error] 142-142: at least two spaces before inline comment
(E261)
[error] 148-148: missing whitespace after ','
(E231)
[error] 148-148: missing whitespace after ','
(E231)
[error] 148-148: missing whitespace after ','
(E231)
[error] 148-148: missing whitespace after ','
(E231)
[error] 151-151: missing whitespace around operator
(E225)
[error] 152-152: missing whitespace around operator
(E225)
[error] 164-164: missing whitespace after ','
(E231)
[error] 164-164: missing whitespace after ','
(E231)
[error] 164-164: missing whitespace after ','
(E231)
[error] 164-164: missing whitespace after ','
(E231)
[error] 164-164: missing whitespace after ','
(E231)
[error] 164-164: missing whitespace after ','
(E231)
[error] 165-165: missing whitespace after ','
(E231)
[error] 165-165: missing whitespace after ','
(E231)
[error] 165-165: missing whitespace after ','
(E231)
[error] 165-165: missing whitespace after ','
(E231)
[error] 165-165: missing whitespace after ','
(E231)
[error] 170-170: missing whitespace after ','
(E231)
[error] 170-170: missing whitespace after ','
(E231)
[error] 170-170: missing whitespace after ','
(E231)
[error] 172-172: missing whitespace after ','
(E231)
[error] 173-173: missing whitespace after ','
(E231)
[error] 174-174: missing whitespace after ','
(E231)
[error] 175-175: missing whitespace after ','
(E231)
[error] 178-178: missing whitespace after ','
(E231)
[error] 178-178: missing whitespace after ','
(E231)
[error] 178-178: missing whitespace after ','
(E231)
[error] 178-178: missing whitespace after ','
(E231)
[error] 180-180: missing whitespace after ','
(E231)
[error] 181-181: missing whitespace after ','
(E231)
[error] 182-182: missing whitespace after ','
(E231)
[error] 185-185: test for object identity should be 'is not'
(E714)
[error] 186-186: missing whitespace after ','
(E231)
[error] 186-186: missing whitespace after ','
(E231)
[error] 186-186: missing whitespace after ','
(E231)
[error] 187-187: test for object identity should be 'is not'
(E714)
[error] 188-188: missing whitespace after ','
(E231)
[error] 188-188: missing whitespace after ','
(E231)
[error] 191-191: too many blank lines (2)
(E303)
[error] 191-191: missing whitespace after ','
(E231)
[error] 192-192: missing whitespace after ','
(E231)
[error] 193-193: missing whitespace after ','
(E231)
[error] 194-194: missing whitespace after ','
(E231)
[error] 195-195: missing whitespace after ','
(E231)
[error] 200-200: test for object identity should be 'is not'
(E714)
[error] 202-202: missing whitespace after ','
(E231)
[error] 202-202: missing whitespace after ','
(E231)
[error] 202-202: missing whitespace after ','
(E231)
[error] 203-203: test for object identity should be 'is not'
(E714)
[error] 205-205: missing whitespace after ','
(E231)
[error] 205-205: missing whitespace after ','
(E231)
[error] 205-205: missing whitespace after ','
(E231)
[error] 206-206: missing whitespace around operator
(E225)
[error] 207-207: missing whitespace after ','
(E231)
[error] 207-207: missing whitespace after ','
(E231)
[error] 209-209: test for object identity should be 'is not'
(E714)
[error] 210-210: missing whitespace after ','
(E231)
[error] 210-210: missing whitespace after ','
(E231)
[error] 212-212: missing whitespace after ','
(E231)
[error] 213-213: missing whitespace after ','
(E231)
[error] 214-214: missing whitespace after ','
(E231)
[error] 217-217: missing whitespace after ','
(E231)
[error] 218-218: missing whitespace after ','
(E231)
[error] 221-221: missing whitespace after ','
(E231)
[error] 222-222: missing whitespace after ','
(E231)
[error] 225-225: missing whitespace after ','
(E231)
🪛 Pylint (3.3.7)
rabies/analysis_pkg/main_wf.py
[refactor] 178-178: Too many arguments (8/5)
(R0913)
[refactor] 178-178: Too many positional arguments (8/5)
(R0917)
scripts/generate_graph.py
[error] 30-30: Undefined variable 'prep_logging'
(E0602)
[error] 33-33: Undefined variable 'install_DSURQE'
(E0602)
[error] 51-51: Undefined variable 'preprocess'
(E0602)
[error] 53-53: Undefined variable 'confound_correction'
(E0602)
[error] 55-55: Undefined variable 'analysis'
(E0602)
[error] 58-58: Possibly using variable 'workflow' before assignment
(E0606)
[refactor] 16-16: Either all return statements in a function should return an expression, or none of them should.
(R1710)
rabies/analysis_pkg/cpca/modeling.py
[refactor] 7-7: Too many arguments (7/5)
(R0913)
[refactor] 7-7: Too many positional arguments (7/5)
(R0917)
[refactor] 51-51: Too many local variables (26/15)
(R0914)
[refactor] 101-101: Too many local variables (28/15)
(R0914)
[refactor] 155-155: Too many arguments (7/5)
(R0913)
[refactor] 155-155: Too many positional arguments (7/5)
(R0917)
[refactor] 155-155: Too many local variables (24/15)
(R0914)
rabies/analysis_pkg/analysis_functions.py
[refactor] 188-188: Too few public methods (0/2)
(R0903)
[refactor] 198-198: Too few public methods (0/2)
(R0903)
[refactor] 219-219: Too many local variables (43/15)
(R0914)
[refactor] 219-219: Too many statements (58/50)
(R0915)
[refactor] 211-211: Too few public methods (0/2)
(R0903)
rabies/analysis_pkg/cpca/report.py
[refactor] 17-17: Too many arguments (6/5)
(R0913)
[refactor] 17-17: Too many positional arguments (6/5)
(R0917)
[refactor] 17-17: Too many local variables (17/15)
(R0914)
[refactor] 39-39: Too many local variables (42/15)
(R0914)
[refactor] 39-39: Too many statements (53/50)
(R0915)
[refactor] 129-129: Too many arguments (6/5)
(R0913)
[refactor] 129-129: Too many positional arguments (6/5)
(R0917)
[refactor] 164-164: Too many arguments (13/5)
(R0913)
[refactor] 164-164: Too many positional arguments (13/5)
(R0917)
[refactor] 164-164: Too many local variables (21/15)
(R0914)
🪛 Ruff (0.11.9)
scripts/generate_graph.py
4-4: SimpleITK imported but unused
Remove unused import: SimpleITK
(F401)
5-5: nipype.logging imported but unused
Remove unused import
(F401)
5-5: nipype.config imported but unused
Remove unused import
(F401)
6-6: from rabies.boilerplate import * used; unable to detect undefined names
(F403)
8-8: from rabies.run_main import * used; unable to detect undefined names
(F403)
10-10: Use key in dict instead of key in dict.keys()
Remove .keys()
(SIM118)
23-23: Do not use bare except
(E722)
30-30: prep_logging may be undefined, or defined from star imports
(F405)
33-33: install_DSURQE may be undefined, or defined from star imports
(F405)
45-48: f-string without any placeholders
Remove extraneous f prefix
(F541)
51-51: preprocess may be undefined, or defined from star imports
(F405)
53-53: confound_correction may be undefined, or defined from star imports
(F405)
55-55: analysis may be undefined, or defined from star imports
(F405)
94-94: f-string without any placeholders
Remove extraneous f prefix
(F541)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
111-111: Test for object identity should be is not
Convert to is not
(E714)
rabies/analysis_pkg/cpca/modeling.py
44-45: Use a single if statement instead of nested if statements
(SIM102)
51-51: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
77-77: Local variable n_t is assigned to but never used
Remove assignment to unused variable n_t
(F841)
101-101: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
131-131: Local variable n_t is assigned to but never used
Remove assignment to unused variable n_t
(F841)
162-162: Test for object identity should be is not
Convert to is not
(E714)
174-174: Comparison to None should be cond is None
Replace with cond is None
(E711)
rabies/analysis_pkg/analysis_functions.py
256-256: f-string without any placeholders
Remove extraneous f prefix
(F541)
292-292: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
293-293: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
294-294: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
295-295: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
296-296: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
301-301: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
302-302: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
303-303: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
304-304: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
305-305: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
rabies/parser.py
1175-1175: Test for membership should be not in
Convert to not in
(E713)
rabies/analysis_pkg/cpca/report.py
8-11: Use ternary operator arr = X.copy() if Y is None else np.concatenate((X, Y), axis=1) instead of if-else-block
Replace if-else-block with arr = X.copy() if Y is None else np.concatenate((X, Y), axis=1)
(SIM108)
133-133: Test for object identity should be is not
Convert to is not
(E714)
152-155: Use ternary operator last_Dc_idx = 0 if len(Dc_idx) == 0 else Dc_idx.max() instead of if-else-block
Replace if-else-block with last_Dc_idx = 0 if len(Dc_idx) == 0 else Dc_idx.max()
(SIM108)
185-185: Test for object identity should be is not
Convert to is not
(E714)
187-187: Test for object identity should be is not
Convert to is not
(E714)
200-200: Test for object identity should be is not
Convert to is not
(E714)
203-203: Test for object identity should be is not
Convert to is not
(E714)
209-209: Test for object identity should be is not
Convert to is not
(E714)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (7)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py (1)
83-83: NPR to CPCA key renaming looks correct.The systematic renaming from NPR keys to CPCA keys aligns with the broader refactoring described in the PR objectives.
Also applies to: 90-90
rabies/analysis_pkg/diagnosis_pkg/interfaces.py (1)
229-235: NPR to CPCA systematic replacement is well-executed.The comprehensive renaming from NPR to CPCA throughout the analysis workflow is consistent and correctly maintains the same logic structure while adapting to the new methodology.
Also applies to: 253-253, 259-260, 403-431
scripts/error_check_rabies.py (1)
190-190: Command-line parameter updates are correct.The replacement of NPR options (
--optimize_NPR,--NPR_temporal_comp) with CPCA options (--CPCA) and their corresponding parameter formats aligns well with the broader refactoring from NPR to CPCA methodology.Also applies to: 217-217
rabies/analysis_pkg/analysis_wf.py (1)
19-20: Workflow transition from NPR to CPCA is well-implemented.The systematic update of output node fields, conditional logic, imports, and node connections correctly reflects the transition from Neural Prior Recovery to Complementary Principal Component Analysis methodology.
Also applies to: 119-140
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py (1)
111-114: NPR to CPCA transition in diagnosis functions is comprehensive and consistent.The systematic replacement of NPR keys, variable names, and references with CPCA equivalents maintains the same functional logic while adapting to the new analysis methodology. The changes span data loading, processing, and visualization functions appropriately.
Also applies to: 127-128, 147-147, 387-388, 420-420, 423-423, 542-558
rabies/analysis_pkg/main_wf.py (1)
168-172: LGTM! NPR to CPCA output connections updated correctlyThe workflow output connections have been properly updated from NPR-prefixed variables to CPCA-prefixed equivalents, maintaining consistency with the new analysis method.
rabies/parser.py (1)
984-1010: LGTM! CPCA argument properly replaces NPR optionsThe new
--CPCAargument correctly consolidates the previous NPR options into a single parameter string with appropriate defaults and comprehensive documentation.
Docstrings generation was requested by @Gab-D-G. * #424 (comment) The following files were modified: * `rabies/analysis_pkg/analysis_functions.py` * `rabies/analysis_pkg/analysis_math.py` * `rabies/analysis_pkg/analysis_wf.py` * `rabies/analysis_pkg/cpca/modeling.py` * `rabies/analysis_pkg/cpca/report.py` * `rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py` * `rabies/analysis_pkg/diagnosis_pkg/diagnosis_wf.py` * `rabies/analysis_pkg/diagnosis_pkg/interfaces.py` * `rabies/analysis_pkg/main_wf.py` * `rabies/parser.py` * `scripts/generate_graph.py`
|
Note Generated docstrings for this pull request at #425 |
|
it's essentially a bunch of syntax corrections, you suggest I address all the suggestions? There's maybe 2-3 things I would change, but that's it personally. |
|
Up to you. It's your software. We generally find it pretty useful. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (11)
rabies/analysis_pkg/cpca/modeling.py (4)
51-51: Fix mutable default argument and parameter formatting.
101-101: Fix mutable default argument and parameter formatting.
162-164: Improve type checking syntax.
174-174: Use identity comparison for None.scripts/generate_graph.py (3)
4-8: Remove unused imports and avoid wildcard imports.
21-25: Avoid bare except clauses.
68-101: Wrap module-level code in main guard.rabies/analysis_pkg/analysis_functions.py (4)
197-207: Fix formatting and clarify CPCA_report output specification.
210-217: Add class documentation.
291-295: Replace setattr with direct assignment.
300-305: Replace getattr with direct attribute access.
🧹 Nitpick comments (2)
rabies/analysis_pkg/cpca/modeling.py (1)
32-203: Address formatting issues for code consistency.The code has numerous formatting issues that should be addressed to improve readability and consistency:
- Missing whitespace after commas in function calls and array indexing
- Missing whitespace around operators
- Inconsistent comment formatting
- Too many blank lines in some places
Consider running a code formatter like
blackorautopep8to automatically fix these issues.rabies/analysis_pkg/analysis_functions.py (1)
241-253: Address formatting issues in CPCA parameter processing.The CPCA parameter processing code has several formatting issues that should be addressed:
- Missing whitespace around comparison operators (lines 242, 245, 248)
- Missing whitespace after commas in the function call (line 251-253)
- Inconsistent line continuation indentation
Apply this diff to fix the formatting:
- if min_prior_sim<0: + if min_prior_sim < 0: min_prior_sim = None - Dc_C_thresh = CPCA_dict['Dc_C_thresh'] - if Dc_C_thresh<0: + Dc_C_thresh = CPCA_dict['Dc_C_thresh'] + if Dc_C_thresh < 0: Dc_C_thresh = None - Dc_W_thresh = CPCA_dict['Dc_W_thresh'] - if Dc_W_thresh<0: + Dc_W_thresh = CPCA_dict['Dc_W_thresh'] + if Dc_W_thresh < 0: Dc_W_thresh = None - Cnet,Wnet,Cs,Ws,Ct,Wt,C,W,fig_list = cpca_auto(X=timeseries, C_prior=C_prior, - N_max=CPCA_dict['n'], Wt_n=CPCA_dict['Wt_n'], min_prior_sim=min_prior_sim, - Dc_W_thresh=Dc_W_thresh, Dc_C_thresh=Dc_C_thresh) + Cnet, Wnet, Cs, Ws, Ct, Wt, C, W, fig_list = cpca_auto( + X=timeseries, C_prior=C_prior, + N_max=CPCA_dict['n'], Wt_n=CPCA_dict['Wt_n'], min_prior_sim=min_prior_sim, + Dc_W_thresh=Dc_W_thresh, Dc_C_thresh=Dc_C_thresh)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
rabies/analysis_pkg/analysis_functions.py(2 hunks)rabies/analysis_pkg/cpca/modeling.py(1 hunks)scripts/generate_graph.py(1 hunks)
🧰 Additional context used
🪛 Ruff (0.11.9)
scripts/generate_graph.py
4-4: SimpleITK imported but unused
Remove unused import: SimpleITK
(F401)
5-5: nipype.logging imported but unused
Remove unused import
(F401)
5-5: nipype.config imported but unused
Remove unused import
(F401)
6-6: from rabies.boilerplate import * used; unable to detect undefined names
(F403)
8-8: from rabies.run_main import * used; unable to detect undefined names
(F403)
10-10: Use key in dict instead of key in dict.keys()
Remove .keys()
(SIM118)
23-23: Do not use bare except
(E722)
30-30: prep_logging may be undefined, or defined from star imports
(F405)
33-33: install_DSURQE may be undefined, or defined from star imports
(F405)
45-48: f-string without any placeholders
Remove extraneous f prefix
(F541)
51-51: preprocess may be undefined, or defined from star imports
(F405)
53-53: confound_correction may be undefined, or defined from star imports
(F405)
55-55: analysis may be undefined, or defined from star imports
(F405)
80-80: f-string without any placeholders
Remove extraneous f prefix
(F541)
rabies/analysis_pkg/cpca/modeling.py
44-45: Use a single if statement instead of nested if statements
(SIM102)
51-51: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
77-77: Local variable n_t is assigned to but never used
Remove assignment to unused variable n_t
(F841)
101-101: Do not use mutable data structures for argument defaults
Replace with None; initialize within function
(B006)
131-131: Local variable n_t is assigned to but never used
Remove assignment to unused variable n_t
(F841)
rabies/analysis_pkg/analysis_functions.py
255-255: f-string without any placeholders
Remove extraneous f prefix
(F541)
291-291: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
292-292: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
293-293: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
294-294: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
295-295: Do not call setattr with a constant attribute value. It is not any safer than normal property access.
Replace setattr with assignment
(B010)
300-300: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
301-301: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
302-302: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
303-303: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
304-304: Do not call getattr with a constant attribute value. It is not any safer than normal property access.
Replace getattr with attribute access
(B009)
🪛 Flake8 (7.2.0)
scripts/generate_graph.py
[error] 4-4: 'SimpleITK as sitk' imported but unused
(F401)
[error] 5-5: 'nipype.logging' imported but unused
(F401)
[error] 5-5: 'nipype.config' imported but unused
(F401)
[error] 6-6: 'from rabies.boilerplate import *' used; unable to detect undefined names
(F403)
[error] 7-7: missing whitespace after ','
(E231)
[error] 8-8: 'from rabies.run_main import *' used; unable to detect undefined names
(F403)
[error] 21-21: at least two spaces before inline comment
(E261)
[error] 23-23: do not use bare 'except'
(E722)
[error] 30-30: 'prep_logging' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 33-33: 'install_DSURQE' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 36-36: too many blank lines (2)
(E303)
[error] 44-44: missing whitespace around operator
(E225)
[error] 44-44: missing whitespace around operator
(E225)
[error] 45-45: f-string is missing placeholders
(F541)
[error] 51-51: 'preprocess' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 53-53: 'confound_correction' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 55-55: 'analysis' may be undefined, or defined from star imports: rabies.boilerplate, rabies.run_main
(F405)
[error] 68-68: module level import not at top of file
(E402)
[error] 70-70: module level import not at top of file
(E402)
[error] 73-73: too many leading '#' for block comment
(E266)
[error] 78-78: too many leading '#' for block comment
(E266)
[error] 80-80: f-string is missing placeholders
(F541)
[error] 80-80: missing whitespace after ','
(E231)
[error] 82-82: block comment should start with '# '
(E265)
rabies/analysis_pkg/cpca/modeling.py
[error] 32-32: missing whitespace after ','
(E231)
[error] 36-36: too many leading '#' for block comment
(E266)
[error] 49-49: missing whitespace after ','
(E231)
[error] 49-49: missing whitespace after ','
(E231)
[error] 51-51: expected 2 blank lines, found 1
(E302)
[error] 51-51: unexpected spaces around keyword / parameter equals
(E251)
[error] 51-51: unexpected spaces around keyword / parameter equals
(E251)
[error] 51-51: missing whitespace after ','
(E231)
[error] 51-51: missing whitespace after ','
(E231)
[error] 51-51: missing whitespace after ','
(E231)
[error] 56-56: missing whitespace around operator
(E225)
[error] 56-56: at least two spaces before inline comment
(E261)
[error] 60-60: at least two spaces before inline comment
(E261)
[error] 63-63: at least two spaces before inline comment
(E261)
[error] 67-67: missing whitespace after ','
(E231)
[error] 67-67: missing whitespace after ','
(E231)
[error] 68-68: missing whitespace after ','
(E231)
[error] 68-68: at least two spaces before inline comment
(E261)
[error] 71-71: missing whitespace after ','
(E231)
[error] 72-72: missing whitespace after ','
(E231)
[error] 74-74: missing whitespace around operator
(E225)
[error] 75-75: missing whitespace around operator
(E225)
[error] 77-77: local variable 'n_t' is assigned to but never used
(F841)
[error] 79-79: missing whitespace after ','
(E231)
[error] 80-80: missing whitespace after ','
(E231)
[error] 83-83: missing whitespace after ','
(E231)
[error] 86-86: at least two spaces before inline comment
(E261)
[error] 87-87: at least two spaces before inline comment
(E261)
[error] 88-88: at least two spaces before inline comment
(E261)
[error] 89-89: missing whitespace after ','
(E231)
[error] 93-93: missing whitespace after ','
(E231)
[error] 94-94: missing whitespace after ','
(E231)
[error] 95-95: missing whitespace after ','
(E231)
[error] 98-98: too many blank lines (2)
(E303)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 98-98: missing whitespace after ','
(E231)
[error] 101-101: unexpected spaces around keyword / parameter equals
(E251)
[error] 101-101: unexpected spaces around keyword / parameter equals
(E251)
[error] 101-101: missing whitespace after ','
(E231)
[error] 101-101: missing whitespace after ','
(E231)
[error] 101-101: missing whitespace after ','
(E231)
[error] 106-106: missing whitespace around operator
(E225)
[error] 106-106: at least two spaces before inline comment
(E261)
[error] 115-115: at least two spaces before inline comment
(E261)
[error] 118-118: missing whitespace after ','
(E231)
[error] 118-118: missing whitespace after ','
(E231)
[error] 121-121: missing whitespace after ','
(E231)
[error] 121-121: at least two spaces before inline comment
(E261)
[error] 123-123: missing whitespace after ','
(E231)
[error] 123-123: at least two spaces before inline comment
(E261)
[error] 125-125: missing whitespace after ','
(E231)
[error] 126-126: missing whitespace after ','
(E231)
[error] 128-128: missing whitespace around operator
(E225)
[error] 129-129: missing whitespace around operator
(E225)
[error] 131-131: local variable 'n_t' is assigned to but never used
(F841)
[error] 133-133: missing whitespace after ','
(E231)
[error] 134-134: missing whitespace after ','
(E231)
[error] 137-137: missing whitespace after ','
(E231)
[error] 140-140: at least two spaces before inline comment
(E261)
[error] 141-141: at least two spaces before inline comment
(E261)
[error] 142-142: at least two spaces before inline comment
(E261)
[error] 143-143: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 148-148: missing whitespace after ','
(E231)
[error] 149-149: missing whitespace after ','
(E231)
[error] 152-152: too many blank lines (2)
(E303)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 152-152: missing whitespace after ','
(E231)
[error] 160-160: missing whitespace around operator
(E225)
[error] 164-164: missing whitespace around operator
(E225)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 169-169: missing whitespace after ','
(E231)
[error] 179-179: missing whitespace after ','
(E231)
[error] 179-179: missing whitespace after ','
(E231)
[error] 181-181: missing whitespace after ','
(E231)
[error] 182-182: missing whitespace after ','
(E231)
[error] 184-184: missing whitespace after ','
(E231)
[error] 185-185: missing whitespace after ','
(E231)
[error] 189-189: missing whitespace after ','
(E231)
[error] 192-192: at least two spaces before inline comment
(E261)
[error] 193-193: at least two spaces before inline comment
(E261)
[error] 194-194: at least two spaces before inline comment
(E261)
[error] 195-195: missing whitespace after ','
(E231)
[error] 199-199: missing whitespace after ','
(E231)
[error] 200-200: missing whitespace after ','
(E231)
[error] 201-201: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
[error] 203-203: missing whitespace after ','
(E231)
rabies/analysis_pkg/analysis_functions.py
[error] 187-187: expected 2 blank lines, found 1
(E302)
[error] 197-197: expected 2 blank lines, found 1
(E302)
[error] 242-242: missing whitespace around operator
(E225)
[error] 245-245: missing whitespace around operator
(E225)
[error] 248-248: missing whitespace around operator
(E225)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 251-251: missing whitespace after ','
(E231)
[error] 252-252: continuation line under-indented for visual indent
(E128)
[error] 253-253: continuation line under-indented for visual indent
(E128)
[error] 255-255: f-string is missing placeholders
(F541)
[error] 263-263: missing whitespace after ','
(E231)
[error] 265-265: missing whitespace around operator
(E225)
[error] 266-266: at least two spaces before inline comment
(E261)
[error] 267-267: at least two spaces before inline comment
(E261)
[error] 268-268: at least two spaces before inline comment
(E261)
[error] 270-270: missing whitespace after ','
(E231)
[error] 280-280: missing whitespace after ','
(E231)
[error] 282-282: missing whitespace around operator
(E225)
[error] 282-282: at least two spaces before inline comment
(E261)
[error] 284-284: missing whitespace after ','
(E231)
[error] 286-286: missing whitespace after ','
(E231)
🪛 Pylint (3.3.7)
scripts/generate_graph.py
[error] 30-30: Undefined variable 'prep_logging'
(E0602)
[error] 33-33: Undefined variable 'install_DSURQE'
(E0602)
[error] 51-51: Undefined variable 'preprocess'
(E0602)
[error] 53-53: Undefined variable 'confound_correction'
(E0602)
[error] 55-55: Undefined variable 'analysis'
(E0602)
[error] 58-58: Possibly using variable 'workflow' before assignment
(E0606)
[refactor] 16-16: Either all return statements in a function should return an expression, or none of them should.
(R1710)
rabies/analysis_pkg/cpca/modeling.py
[refactor] 7-7: Too many arguments (7/5)
(R0913)
[refactor] 7-7: Too many positional arguments (7/5)
(R0917)
[refactor] 51-51: Too many local variables (26/15)
(R0914)
[refactor] 101-101: Too many local variables (28/15)
(R0914)
[refactor] 155-155: Too many arguments (7/5)
(R0913)
[refactor] 155-155: Too many positional arguments (7/5)
(R0917)
[refactor] 155-155: Too many local variables (24/15)
(R0914)
rabies/analysis_pkg/analysis_functions.py
[refactor] 187-187: Too few public methods (0/2)
(R0903)
[refactor] 197-197: Too few public methods (0/2)
(R0903)
[refactor] 218-218: Too many local variables (43/15)
(R0914)
[refactor] 218-218: Too many statements (58/50)
(R0915)
[refactor] 210-210: Too few public methods (0/2)
(R0903)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (3)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py (3)
111-111: Use 'is not' for None comparison.The current syntax can be improved for better readability and PEP 8 compliance.
- if not analysis_dict['CPCA_prior_filename'] is None: + if analysis_dict['CPCA_prior_filename'] is not None:
147-147: Fix formatting: add missing whitespace after commas.The line has multiple missing spaces after commas, which affects code readability.
- del temporal_info['DR_all'], temporal_info['DR_bold'],temporal_info['DR_confound'],temporal_info['CPCA_time'],temporal_info['SBC_time'] + del temporal_info['DR_all'], temporal_info['DR_bold'], temporal_info['DR_confound'], temporal_info['CPCA_time'], temporal_info['SBC_time']
387-388: Fix formatting: add missing whitespace after commas.Both lines have missing spaces after commas in the array and list definitions.
- [temporal_info['DR_confound'], temporal_info['DR_bold'],temporal_info['SBC_time'],temporal_info['CPCA_time']], - ['DR confounds', 'DR networks','SBC networks','CPCA networks'], + [temporal_info['DR_confound'], temporal_info['DR_bold'], temporal_info['SBC_time'], temporal_info['CPCA_time']], + ['DR confounds', 'DR networks', 'SBC networks', 'CPCA networks'],
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py(8 hunks)rabies/confound_correction_pkg/confound_correction.py(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- rabies/confound_correction_pkg/confound_correction.py
🧰 Additional context used
🪛 Ruff (0.11.9)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
111-111: Test for object identity should be is not
Convert to is not
(E714)
🪛 Flake8 (7.2.0)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py
[error] 147-147: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 147-147: missing whitespace after ','
(E231)
[error] 387-387: missing whitespace after ','
(E231)
[error] 387-387: missing whitespace after ','
(E231)
[error] 388-388: missing whitespace after ','
(E231)
[error] 388-388: missing whitespace after ','
(E231)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: build
🔇 Additional comments (5)
rabies/analysis_pkg/diagnosis_pkg/diagnosis_functions.py (5)
111-114: LGTM! Consistent renaming from NPR to CPCA.The conditional loading logic has been correctly updated to use CPCA parameter names while maintaining the same functionality.
127-128: LGTM! Dictionary keys updated consistently.The spatial and temporal info dictionaries now correctly use CPCA keys instead of NPR keys.
420-423: LGTM! Consistent variable renaming from NPR to CPCA.The spatial info extraction and nrows calculation have been correctly updated to use CPCA maps instead of NPR maps.
542-558: LGTM! Plot generation updated for CPCA networks.The plotting loop has been correctly updated to use CPCA maps and display appropriate titles for CPCA networks while maintaining the same visualization logic.
6-6: To pinpointvcorrcoefin the new module, let’s search directly withinanalysis_math.pyusing ripgrep:#!/bin/bash # Locate vcorrcoef definition in analysis_math module rg -n "def vcorrcoef" -g "**/analysis_math.py"
CMonnin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ignore my comment about the self.inputs is see it's just a nypipe thing.
Looks good to me
| from rabies.analysis_pkg.cpca.modeling import cpca_auto | ||
|
|
||
| import pickle | ||
| with open(self.inputs.dict_file, 'rb') as handle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should self.inputs be self.input_spec in this function?
|
@Gab-D-G I think the CPCA code should be its own python package, that exports functions that is then installed and imported into the RABIES pipeline. This is because it will have a larger audience and uses if its packaged this way. Do you need help converting your code to this? |
This is my plan. I haven't done it yet, and that's the main reason i have not merged yet. I think its best in the end to wait until the CPCA package is ready. |
|
@CMonnin Can help on the technicals here |
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
Chores