[Neuroimaging] what's the problem??????
נתי שטרן
nsh531 at gmail.com
Thu Jul 14 01:49:39 EDT 2022
Instead of numbers, I want to enter as indexes the names of the Index as
being in b variable:
labels = pd.read_csv(
"C:/Users/Administrator/Desktop/64/64/labels_64_dictionary.csv")
a=labels.to_dict()
b=a["Difumo_names"]
בתאריך יום ה׳, 14 ביולי 2022 ב-7:44 מאת <avi.e.gross at gmail.com>:
> Nati,
>
> I know you think you are communicating.
>
> שטרן >> I want to swap indexes of dict
>
> When you say SWAP, do you mean replace the index with something else, or
> swap the key and value or something entirely else?
>
> You have not shared an example of what is in your dictionary, but say it
> is:
>
> myDict = {1:"a", 2:"b", 3:"c"}
>
> invDict = { value:key for key, value in myDict.items() }
>
> print(myDict)
> print(invDict)
>
>
> The above prints out:
>
> print(myDict)
> {1: 'a', 2: 'b', 3: 'c'}
>
> print(invDict)
> {'a': 1, 'b': 2, 'c': 3}
>
> It obviously generalizes only for dictionaries where all values are
> unique. And you can obviously save the results back into the same variable
> if you wish. The above comprehension may, of course, not be what you want
> as swapping indexes with <UNSPECIFIED> may not mean anything to us trying
> to help.
>
> Avi (a שטרן on my mother's side.)
>
>
> -----Original Message-----
> From: Python-list <python-list-bounces+avi.e.gross=gmail.com at python.org>
> On Behalf Of ??? ????
> Sent: Thursday, July 14, 2022 12:19 AM
> To: David Welch <david.m.welch at gmail.com>; Neuroimaging analysis in
> Python <neuroimaging at python.org>; python-list at python.org
> Subject: Re: [Neuroimaging] what's the problem??????
>
> I want to swap indexes of dict
>
> בתאריך יום ד׳, 13 ביולי 2022, 21:51, מאת David Welch <
> david.m.welch at gmail.com>:
>
> >
> >> - Describe the research *you did* to try and understand the problem
> >> *before* you asked the question.
> >> - Describe the diagnostic steps *you took* to try and pin down the
> >> problem yourself *before* you asked the question.
> >>
> >>
> > On Wed, Jul 13, 2022 at 1:47 PM David Welch <david.m.welch at gmail.com>
> > wrote:
> >
> >> From http://catb.org/~esr/faqs/smart-questions.html#beprecise:
> >>
> >>> Be precise and informative about your problem
> >>>
> >>> -
> >>>
> >>> Describe the symptoms of your problem or bug carefully and clearly.
> >>> -
> >>>
> >>> Describe the environment in which it occurs (machine, OS,
> >>> application, whatever). Provide your vendor's distribution and
> release
> >>> level (e.g.: “Fedora Core 7”, “Slackware 9.1”, etc.).
> >>> -
> >>>
> >>> Describe the research you did to try and understand the problem
> >>> before you asked the question.
> >>> -
> >>>
> >>> Describe the diagnostic steps you took to try and pin down the
> >>> problem yourself before you asked the question.
> >>> -
> >>>
> >>> Describe any possibly relevant recent changes in your computer or
> >>> software configuration.
> >>> -
> >>>
> >>> If at all possible, provide a way to *reproduce the problem in a
> >>> controlled environment*.
> >>>
> >>> Do the best you can to anticipate the questions a hacker will ask,
> >>> and answer them in advance in your request for help.
> >>>
> >>> Giving hackers the ability to reproduce the problem in a controlled
> >>> environment is especially important if you are reporting something
> >>> you think is a bug in code. When you do this, your odds of getting a
> >>> useful answer and the speed with which you are likely to get that
> >>> answer both improve tremendously.
> >>>
> >>> Simon Tatham has written an excellent essay entitled How to Report
> >>> Bugs Effectively
> >>> <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>. I strongly
> recommend that you read it.
> >>>
> >>>
> >>
> >> ---------- Forwarded message ---------
> >> From: נתי שטרן <nsh531 at gmail.com>
> >> Date: Wed, Jul 13, 2022 at 1:36 PM
> >> Subject: Re: [Neuroimaging] what's the problem??????
> >> To: Neuroimaging analysis in Python <neuroimaging at python.org>, <
> >> python-list at python.org>
> >>
> >>
> >> I want to set dict
> >>
> >> בתאריך יום ד׳, 13 ביולי 2022, 20:47, מאת נתי שטרן <nsh531 at gmail.com>:
> >>
> >>> CODE:
> >>>
> >>> for nii in os.listdir("c:/users/administrator/desktop/nii"):
> >>>
> >>> from nilearn import plotting
> >>> from nilearn import datasets
> >>> atlas = datasets.fetch_atlas_msdl()
> >>> # Loading atlas image stored in 'maps'
> >>> atlas_filename =
> >>> "C:/Users/Administrator/Desktop/64/64/2mm/maps.nii.gz"
> >>> # Loading atlas data stored in 'labels'
> >>> labels = pd.read_csv(
> >>> "C:/Users/Administrator/Desktop/64/64/labels_64_dictionary.csv")
> >>> a=labels.to_dict()
> >>> b=a["Difumo_names"]
> >>> from nilearn.maskers import NiftiMapsMasker
> >>> masker = NiftiMapsMasker(maps_img=atlas_filename, standardize=True,
> >>> memory='nilearn_cache', verbose=5)
> >>>
> >>> time_series = masker.fit_transform(
> >>> "c:/users/administrator/desktop/nii/"+nii)
> >>> try:
> >>> from sklearn.covariance import GraphicalLassoCV
> >>> except ImportError:
> >>> # for Scitkit-Learn < v0.20.0
> >>> from sklearn.covariance import GraphLassoCV as
> >>> GraphicalLassoCV
> >>>
> >>> estimator = GraphicalLassoCV()
> >>> estimator.fit(time_series)
> >>> # Display the covariancec
> >>> aas={}
> >>> jsa=0
> >>> for i in estimator.covariance_:
> >>> r=list(a["Difumo_names"].values())[jsa]
> >>> jsa=jsa+1
> >>> a=dict()
> >>>
> >>>
> >>> for x in range(64):
> >>> g=list(a["Difumo_names"].values())[x]
> >>>
> >>> print(aas)
> >>> t= nilearn.plotting.plot_img(estimator.covariance_,
> labels=list(a[
> >>> "Difumo_names"].values()),
> >>> figure=(9, 7), vmax=1, vmin=-1,
> >>> title='Covariance')# The covariance can be
> >>> found at estimator.covariance_
> >>>
> >>> # The covariance can be found at estimator.covariance_
> >>> t2= nilearn.plotting.plot_matrix(estimator.covariance_,
> >>> labels=list (a["Difumo_names"].values()),
> >>> figure=(9, 7), vmax=1, vmin=-1,
> >>> title='Covariance')
> >>>
> >>>
> >>>
> >>> --
> >>> <https://netanel.ml>
> >>>
> >> _______________________________________________
> >> Neuroimaging mailing list
> >> Neuroimaging at python.org
> >> https://mail.python.org/mailman/listinfo/neuroimaging
> >>
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
--
<https://netanel.ml>
More information about the Python-list
mailing list