Skip to content

Releases: donishadsmith/neurocaps

0.12.1

28 Jun 01:45
Compare
Choose a tag to compare

♻ Changed

  • For merge_dicts sorts the run keys lexicographically so that subjects that don't have the earliest run-id in the
    first dictionary due to not having that run or the run being excluded still have ordered run keys in the merged
    dictionary.

💻 Metadata

  • Updates runs parameters type hints so that it is known that strings can be used to0.

0.12.0

26 Jun 21:57
Compare
Choose a tag to compare
  • Entails some code cleaning and verification to ensure that the code cleaned for clarity purposes produces the same
    results.

🚀 New/Added

  • Davies Bouldin and Variance Ratio (Calinski Harabasz) added

♻ Changed

  • For CAPs.calculate_metrics() if performing an analysis on groups where each group has a different number of CAPs, then for "temporal_fraction",
    "persistence", and "counts", "nan" values will be seen for CAP numbers that exceed the group's number of CAPs.
    • For instance, if group "A" has 2 CAPs but group "B" has 4 CAPs, the DataFrame will contain columns for CAP-1,
      CAP-2, CAP-3, and CAP-4. However, for all members in group "A", CAP-3 and CAP-4 will contain "nan" values to
      indicate that these CAPs are not applicable to the group. This differentiation helps distinguish between CAPs
      that are not applicable to the group and CAPs that are applicable but had zero instances for a specific member.

🐛 Fixes

  • Adds error earlier when tr is not specified or able to be retrieved form the bold metadata when the condition is specified
    instead of allowing the pipeline to produce this error later.
  • Fixed issue with show_figs in CAP.caps2surf() showing figure when set to False.

0.11.3

25 Jun 00:58
Compare
Choose a tag to compare

♻ Changed

  • With parallel processing, joblib outputs are now returned as a generator as opposed to the default, which is a list,
    to reduce memory usage

0.11.2

24 Jun 02:41
Compare
Choose a tag to compare

♻ Changed

  • Changed how ids are organized in respective group when initializing the CAP class. In version 0.11.1, the ids are
    sorted lexicographically:
self._groups[group] = sorted(list(set(self._groups[group])))

This doesn't affect functionality but it may be better to respect the original user ordering.This is no longer the case.

0.11.1

23 Jun 08:08
Compare
Choose a tag to compare

🐛 Fixes

  • Fix for python 3.12 when using CAP.caps2surf().
    • Changes in pathlib.py in Python 3.12 results in an error message format change. The error message now includes
      quotes (e.g., "not 'Nifti1Image'") instead of the previous format without quotes ("not Nifti1Image"). This issue
      arises when using neuromaps.transforms.mni_to_fslr within CAP.caps2surf() as neuromaps captures the error as a
      string and checks if "not Nifti1Image" is in the string to determine if the input is a NifTI image. As a patch,
      if the error occurs, a temporary .nii.gz file is created, the statistical image is saved to this file, and it is
      used as input for neuromaps.transforms.mni_to_fslr. The temporary file is deleted after use. Below is the code
      implementing this fix.
# Fix for python 3.12, saving stat_map so that it is path instead of a NifTI
try:
    gii_lh, gii_rh = mni152_to_fslr(stat_map, method=method, fslr_density=fslr_density)
except TypeError:
    # Create temp
    temp_nifti = tempfile.NamedTemporaryFile(delete=False, suffix=".nii.gz")
    warnings.warn(textwrap.dedent(f"""
                    Error potentially due to change in pathlib.py in python 3.12 causing the error
                    message to output as "not 'Nifti1Image'" instead of "not Nifti1Image", which
                    neuromaps uses to determine if the input is a Nifti1Image object.
                    Converting stat_map into a temporary nii.gz file (which will be automatically
                    deleted afterwards) at {temp_nifti.name}
                    """))
    # Ensure file is closed
    temp_nifti.close()
    # Save temporary nifti to temp file
    nib.save(stat_map, temp_nifti.name)
    gii_lh, gii_rh = mni152_to_fslr(temp_nifti.name, method=method, fslr_density=fslr_density)
    # Delete
    os.unlink(temp_nifti.name)
  • Final patch is for strings in triple quotes. The standard textwrap module is used to remove the indentations at each
    new line.

0.11.0

22 Jun 04:39
Compare
Choose a tag to compare

🚀 New/Added

  • Added new function change_dtype to make it easier to change the dtypes of each subject's numpy array to assist with
    memory usage, especially if doing the CAPs analysis on a local machine.
  • Added new parameters - output_dir, file_name, and return_dict tostandardizeto save dictionary, the return_dict` defaults to True.
  • Adds a new version attribute so you can check the current version using neurocaps.__version__

♻ Changed

  • Adds back python 3.12 classifier. The CAP.caps2surf() function may still not work well but if its detected that
    neurocaps is being installed using python 3.12, setuptools is installed to prevent the pkgresources error.

🐛 Fixes

  • Minor fix for file_name parameter in merge_dicts. If user does not supply a file_name when saving the dictionary,
    it will provide a default file_name now instead of producing a Nonetype error.

💻 Metadata

  • Minor docstrings revisions, mostly to the typehint for subject_timeseries.

0.10.0

18 Jun 01:30
Compare
Choose a tag to compare

Versioning Notice

Affected Versions: 1.0.0 through 1.0.0.post4

Due to a versioning mistake, versions 1.0.0 through 1.0.0.post4 were released in error. These versions have now been
removed from pypi. The correct versioning was intended to be incremented from 0.9.9 to 0.10.0.

All changes and fixes from the erroneous versions have been included in version 0.10.0, along with some additional
updates.

Please use version 0.10.0 or later:

pip install neurocaps==0.10.0

For local installations, you may need to run:

pip uninstall neurocaps
pip install -e .

[0.10.0] - 2024-06-17

🚀 New/Added

  • CAP class as a cosine_similarity property and in CAP.caps2radar, there is now a as_html parameter to save
    plotly's radar plots as an html file instead of a static png. The html files can be opened in a browser and saved as a
    png from the browser. Most importantly, they are interactive. - new to [0.10.0]
  • Made another internal attribute in CAP CAP.subject_table a property and setter. This property acts as a lookup
    table. As a setter, it can be used to modify the table to use another subject dictionary with different subjects
    not used to generate the k-means model.
  • Can now plot silhouette score and have some control over the x-axis of elbow and silhouette plot with the "step" **kwarg.

♻ Changed

  • Default for CAP.caps2plots() from "outer product" to "outer_product".
  • Default for CAP.calculate_metrics() from "temporal fraction" to "temporal_fraction" and "transition frequency"
    to "transition_frequency".
  • n_clusters and cluster_selection_method parameters moved to CAP.get_caps instead of being parameters in
    CAP.

🐛 Fixes

  • Restriction that numpy must be less than version 2 since this breaks brainspace vtk, which is needed for plotting to
    surface space. - new to [0.10.0]
  • Adds nbformat as dependency for plotly. - new to [0.10.0]
  • In TimeseriesExtractor.get_bold(), several checks are done to ensure that subjects have the necessary files for
    extraction. Subjects that have zero nifti, confound files (if confounds requested), event files (if requested), etc
    are automatically eliminated from being added to the list for timeseries extraction. A final check assesses, the run
    ID of the files to see if the subject has at least one run with all necessary files to avoid having subjects with all
    the necessary files needed but all are from different runs. This is most likely a rare occurrence but it is better to be
    safer to ensure that even a rare occurrence doesn't result in a crash. The continue statement that skips the subject
    only worked if no condition was specified.
  • Removes in-place operations when standardizing to avoid numpy casting issues due to incompatible dtypes.
  • Additional deep copy such as deep copying any setter properties to ensure external changes does not result internal
    changes.
  • Some important fixes were left out of the original version.
    • These fixes includes:
      • Removal of the epsilon parameter in self.get_caps and replacement with std[std < np.finfo(np.float64).eps] = 1.0
        to prevent divide by 0 issues and numerical instability issues.
      • Deep copy subject_timeseries in standardize() and parcel_approach. In their functions, in-place operations
        are performed which could unintentionally change the external versions of these parameters
  • Added try-except block in TimeseriesExtractor.get_bold when attempting to obtain the tr, to issue a warning
    when tr isn't specified and can't be extracted from BOLD metadata. Extraction will be continued.
  • Fixed error when using silhouette method without multiprocessing where the function called the elbow method instead
    of the silhouette method. This error affects versions 0.9.6 to 0.9.9.
  • Fix some file names of output by adding underscores for spaces in group names.